Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
- <meta charset="UTF-8">
- `<?php
- //Create connection credentials
- $db_host = 'localhost';
- $db_name = 'quizzer';
- $db_user = 'root';
- $db_pass = '';
- $mysqli = new mysqli ($db_host, $db_user, $db_pass, $db_name);
- if($mysqli->connect_error){
- printf("Connect failed: %sn", $mysqli->connect_error);
- exit();
- }
- //Set question number
- $number = (int) $_GET['n'];
- /*
- * Get total questions
- */
- $query = "SELECT * FROM `questions`";
- //Get result
- $results = $mysqli->query($query) or die($mysqli->error.__LINE__);
- $total = $results->num_rows;
- /*
- * Get Question
- */
- $query = "SELECT * FROM `questions`
- WHERE question_number = $number";
- //Get result
- $result = $mysqli->query($query) or die($mysqli->error.__LINE__);
- $question = $result->fetch_assoc();
- /*
- * Get Choices
- */
- $query = "SELECT * FROM `choices`
- WHERE question_number = $number";
- //Get results
- $choices = $mysqli->query($query) or die($mysqli->error.__LINE__);
- <?php $question['question_number']; ?> of <?php echo $total; ?>
- <?php echo $question['text']; ?>
- <?php while($row = $choices->fetch_assoc()): ?>
- <?php echo $row['id']; ?>" /><?php echo $row['text']; ?>
- <?php endwhile; ?>`
Add Comment
Please, Sign In to add comment