的這部分代碼工作正常:PHP不會在不同的格呼應相同的代碼
<div id="Vraag">
<?php
while($row = mysqli_fetch_assoc($rows))
{
echo $row["vraag"];
}
?>
</div>
但這部分不工作:
<div id="antAA">
<?php
while($row = mysqli_fetch_assoc($rows))
{
echo $row["AntwA"];
}
?>
<!-- <a href="#" id="antAA">Antwoord A</a> -->
</div>
而且我不知道爲什麼它是不工作。它是相同的代碼。
while($row = mysqli_fetch_assoc($rows))
{
echo $row["id"];
echo $row["vraag"];
echo $row["AntwA"];
echo $row["AntwB"];
echo $row["AntwC"];
echo $row["AntwD"];
}
但在div它是行不通的:因爲如果我在我的代碼的頂部呼應他們的一切優秀運行這段代碼一路數據庫工作正常。如果需要的話
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="se.css">
<title>Lotto</title>
</head>
<body>
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "lotto";
$db = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$query = "SELECT id, vraag, AntwA, AntwB, AntwC, AntwD,id FROM vraag1";
$rows = mysqli_query($db, $query);
// while($row = mysqli_fetch_assoc($rows))
// {
// echo $row["id"];
// echo $row["vraag"];
// echo $row["AntwA"];
// echo $row["AntwB"];
// echo $row["AntwC"];
// echo $row["AntwD"];
// }
?>
<div id="headerbg"></div>
<center>
<h1>Vraag 1</h1>
</center>
<center>
<div>
<img src="antw.png" id="img6">
</div>
<div id="Vraag">
<?php
while($row = mysqli_fetch_assoc($rows))
{
echo $row["vraag"];
}
?>
</div>
<div id="plaatje">
<img id="img1" src="wip.jpg">
</div>
<div id="BGantA">
<img id="img2" src="antw.png">
</div>
<div id="antAA">
<?php
while($row = mysqli_fetch_assoc($rows))
{
echo $row["vraag"];
}
?>
<!-- <a href="#" id="antAA">Antwoord A</a> -->
</div>
<div>
<img src="antw.png" id="img3">
</div>
<div>
<a href="#" id="antBB">Antwoord B</a>
</div>
<div>
<img src="antw.png" id="img4">
</div>
<div>
<a href="#" id="antCC">Antwoord C</a>
</div>
<div>
<img src="antw.png" id="img5">
</div>
<div>
<a href="#" id="antDD">Antwoord D</a>
</div>
</center>
</body>
</html>
CSS代碼:
body{
background-color: white;
overflow: hidden;
/*#ECECEC;*/
}
#headerbg{
display: block;
margin-top:-10px;
margin-left: -10px;
margin-right: -10px;
width: 102%;
height: 118px;
background-color: #333333;
/*#232323;*/
}
h1{
font-family: times;
display: block;
margin-left: -800px;
margin-top:-76px;
color: #979797;
}
#img2, #img3, #img4, #img5{
width:300px;
height:100px;
display: block;
}
img{
border:1px solid lightgray;
padding: 5px;
}
#img1{
margin-top: 50px;
}
#img2{
margin-top: -370px;
margin-left: -800px;
}
#img3{
margin-top:-67px;
margin-left:800px;
}
#img4{
margin-left:-800px;
margin-top: 150px;
}
#img5{
margin-left: 800px;
margin-top: -67px;
}
#img6{
display: block;
width: 800px;
height: 60px;
margin-top: 55px;
margin-left: ;
}
#antAA, #antBB, #antCC, #antDD{
display: block;
/*color: #979797;*/
color:red;
text-decoration:none;
}
#antAA, #antCC{
margin-top: -65px;
margin-right: 800px;
}
#antBB{
margin-top: -65px;
margin-left: 800px;
}
#antDD{
margin-left: 800px;
margin-top:-65px;
}
#Vraag{
display:block;
color: red;
margin-top: -44px;
}
#antAA:hover, #antBB:hover, #antCC:hover, #antDD:hover{
color:white;
}
提交你想....整個代碼在這裏你的問題是不是dectectable什麼.. –
你在查詢結果兩次循環 –