-4

# I am making a online exam system and I want to add radio button in the options section, but when I add, it's showing error. How do I add radio button to options section#

And also code for next and previous button to fetch data from database

<!DOCTYPE html>
        <html lang="en">
        <head>
        <meta charset="UTF-8">
        <title>Question Show</title>
        </head>
        <body>
        <?php
        // database
        $con = mysqli_connect('localhost','root','');
        mysqli_select_db($con, 'Question');
        //  results per page
        $results_per_page = 1;
        // find out the number of results stored in database
        $sql='SELECT * FROM tableoption';
        $result = mysqli_query($con, $sql);
        $number_of_results = mysqli_num_rows($result);
        // determine number of total pages available
        $number_of_pages = ceil($number_of_results/$results_per_page);
        // determine which page number visitor is currently on
        if (!isset($_GET['page'])) {
          $page = 1;
        } else {
          $page = $_GET['page'];
        }
        // determine the sql LIMIT starting number for the results on the displaying page
        $this_page_first_result = ($page-1)*$results_per_page;
        // retrieve selected results from database and display them on page
        $sql='SELECT * FROM tableoption LIMIT ' . $this_page_first_result . ',' .  $results_per_page;
        $result = mysqli_query($con, $sql);
        while($row = mysqli_fetch_array($result)) {
        echo $row['id'] . ' ' . $row['tableoption']. '<br>';
        echo $row['opt1']. '<br>';
        echo $row['opt2']. '<br>';
        echo $row['opt3']. '<br>';
        echo $row['opt4']. '<br>';
        }
        // display the links to the pages
        for ($page=1;$page<=$number_of_pages;$page++) {
          echo '<a href="index.php?page=' . $page . '">' . $page . '</a> ';
        }
        ?>
        </body>
        </html>

Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\Paginaton\index.php on line 33

 <th>
        <td><input type="radio" value="<?php echo $row['opt1']. ?>'<br>';/></td>

        </th>
Ravi Sahu
  • 1
  • 1

2 Answers2

0

This

<td><input type="radio" value="<?php echo $row['opt1']. ?>'<br>';/></td>

Should be this

<td><input type="radio" value="<?php echo $row['opt1']; ?>" /><br /></td>
Jesse Schokker
  • 896
  • 7
  • 19
0

You forgot to close the value attribute of your input.

<input type="radio" value="<?php echo $row['opt1']; ?>"/>
Gene M
  • 348
  • 2
  • 12