I have a html file showing a quiz webside with questions and answers and a php file getting the questions from my local mysql server.
The html file and the php file are working fine, but now I want to get the data from the server when the side is loaded and put the data into the right buttons and labels (Loading a question and the answers and display it on my prefabricated html file).
This is my php code how i get the question from my database:
$round = $_POST['round'];
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}else{
$sql = "select * from questions where round = $round order by rand()
limit 1;";
while($row = mysql_fetch_assoc($sql)) {
echo $row['id'] . " " . $row['category'] . " " . $row['round'] .
" " . $row['question'] . " " . $row['rightanswer'] . " " .
$row['wronganser1'] . " " . $row['wronganser2'] . " " .
$row['wronganser3'];
}...
and this is my html file displaying the label and buttons with the question and answers:
<div id="question">
<h4 id="category">Kunst und Literatur</h4>
<p style="margin-bottom: 0px" class="question">Question=</p>
</div>
<ul id="answers">
<li id="answer1" class="button">Answer1</li>
<li id="answer2" class="button">Answer2</li>
<li id="answer3" class="button">Answer3</li>
<li id="answer4" class="button" style="margin-bottom: 0px">Answer4</li>
</ul>...
Instead of "Question" and "Answer1","Answer2"... i want the data loaded from my server.
I appreciate every idea and if anything is unclear don't hesitate to ask.
Thanks :)