Dieser Teil des Codes funktioniert:PHP Wird nicht denselben Code in verschiedenen div Echo
<div id="Vraag">
<?php
while($row = mysqli_fetch_assoc($rows))
{
echo $row["vraag"];
}
?>
</div>
Aber dieser Teil nicht funktioniert:
<div id="antAA">
<?php
while($row = mysqli_fetch_assoc($rows))
{
echo $row["AntwA"];
}
?>
<!-- <a href="#" id="antAA">Antwoord A</a> -->
</div>
Und ich habe keine Ahnung, warum es funktioniert nicht. Es ist der gleiche Code. Die Datenbank funktioniert gut, denn wenn ich diesen Code ausführen es den ganzen Weg in der Spitze von meinem Code hallt sie alle fein:
while($row = mysqli_fetch_assoc($rows))
{
echo $row["id"];
echo $row["vraag"];
echo $row["AntwA"];
echo $row["AntwB"];
echo $row["AntwC"];
echo $row["AntwD"];
}
Aber im div es funktioniert einfach nicht.
<!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-Code bei Bedarf:
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;
}
einreichen, was Sie versuchen .... der gesamte Code hier Ihr Problem nicht dectectable ist .. –
Sie zweimal über das Abfrageergebnis werden looping –