Od dawna próbuję zrobić quiz i nie mogę oto kod
<?php include "database.php"; ?>
<?php session_start(); ?>
<?php
//Set question number
$number = (int) $_GET['question_number'];
//Get total number of questions
$query = "SELECT * FROM pytania";
$results = $mysqli->query($query) or die($mysqli->error.__LINE__);
$total=$results->num_rows;
// Get Question
$query = "SELECT * FROM pytania where id = $number";
//Get result
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);
$question = $result->fetch_assoc();
// Get Choices
$query = "SELECT * FROM pytania where id = $number";
//Get results
$choices = $mysqli->query($query) or die($mysqli->error.__LINE__);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>PHP Quizzer!</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
</head>
<body>
<div id="container">
<header>
<div class="container">
<h1>PHP Quizzer</h1>
</div>
</header>
<main>
<div class="container">
<div class="current">Question <?php echo $number; ?> of <?php echo $total; ?></div>
<p class="question">
<?php echo $question['question'] ?>
</p>
<form method="post" action="proces.php">
<ul class="choices">
<?php while($row=$choices->fetch_assoc()): ?>
<li><input name="choice" type="radio" value="<?php echo $row['id']; ?>" />
<?php echo $row['choice']; ?>
</li>
<?php endwhile; ?>
</ul>
<input type="submit" value="submit" />
<input type="hidden" name="number" value="<?php echo $number; ?>" />
</form>
baza mysql wygląda tak
W pierszej tabeli
question_name|pytanie
a w drugiej
id |
|question_number |
|is_correct |
|choice |