Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <form method = "post" action = "get.php">
- <input type="submit" value="Next" onclick = 'document.getElementById("id").value++; ' />
- <input type="text" name="id" id = "id" />
- </form>
- <?php
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "gin446";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $id= $_POST['id'];
- echo $id;
- $sql = "SELECT `question`,`choice1`,`choice2`,`choice3`,`choice4` FROM quiz where id = $id";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo " ".$row["question"]." <br> ";
- for ( $i = 1 ; $i < 5 ; $i++) {
- if ($row["choice".$i.""] != null )
- echo "<input type='radio'/> " . $row["choice".$i.""]. "<br>";
- }
- }
- } else {
- echo "0 results";
- }
- $conn->close();
- }
- ?>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement