我如何在我的PHP代码中添加单选按钮以及下一个和上一个按钮[重复]

问题描述 投票:-4回答:2

#我正在制作在线考试系统,我想在选项部分添加单选按钮,但是当我添加时,它显示错误。如何在选项部分添加单选按钮#

还有下一个和上一个按钮的代码,用于从数据库中获取数据

<!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>

解析错误:语法错误,第33行的C:\ xampp \ htdocs \ Paginaton \ index.php中的意外“<”

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

        </th>
php html
2个回答
0
投票

这个

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

应该是这个

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

0
投票

您忘记关闭输入的value属性。

<input type="radio" value="<?php echo $row['opt1']; ?>"/>
© www.soinside.com 2019 - 2024. All rights reserved.