duanliaouu965826 2016-03-08 10:20
浏览 6

如何突出每个问题的状态是否回答

I am working on an quiz page.In this there are radio buttons corresponding to each question.I have to view the status of each question whether answered or not.please give me any solution to do this.

here is my code

  <?php 
 error_reporting(E_ALL ^ E_DEPRECATED);
$rs=mysql_query("select * from question where testid=$tid order by quesid ",$cn) or die(mysql_error());

if($_SESSION[qn]>mysql_num_rows($rs)-1)
{
unset($_SESSION[qn]);
echo "<h1 class=\"head1\">Some Error  Occured</h1>";
session_destroy();
echo "Please <a href=\"UserHome.php\"> Start Again</a>";

exit;
}
        ?>
        <form name="myfm" id="myfm" method="post" action="QuizSub.php">
        <table width="100%">  
        <?php
        $n=0;
        while($row= mysql_fetch_row($rs)){?>

        <tr> <td width="30"></td><td></td></tr> 
        <?php $n=$n+1; ?>
        <tr><td>Question <?php echo $n.") ".$row[2]; ?></td></tr>
    <tr><td class="style8">A. <input type="radio" name="ques<?php echo $n; ?>[]" value="1"><?php echo $row[3]; ?></td></tr>
    <tr><td class="style8">B. <input type="radio" name="ques<?php echo $n; ?>[]" value="2"><?php echo $row[4];?></td></tr>
    <tr><td class="style8">C. <input type="radio" name="ques<?php echo $n; ?>[]"  value="3"><?php echo $row[5];?></td></tr>
    <tr><td class="style8">D. <input type="radio" name="ques<?php echo $n; ?>[]"  value="4"><?php echo $row[6];?></td></tr>

    <?php 
        }
        echo "<tr><td><input type=\"hidden\" name=\"qncount\" id=\"qncount\" value=\"".$n."\"><input type=\"submit\" name=\"submit\" id=\"result\" value=\"Get Result\"></td></tr>";
        ?>
        </table>
        </form>

  • 写回答

3条回答 默认 最新

  • donglang9880 2016-03-08 10:46
    关注

    If you're trying to stop people from submitting unchecked question answers - in your case - the easiest thing to do is for every answer: make one checked by default.

    <input type="radio" checked />
    

    For unattended radio buttons, target the name you're using ie:

    <form method="post">
    <input type="radio" value="1" name="example">
    </form>
    

    and then POST it to a PHP file. You can then check if its unattended by doing:

    <?php
    if(!isset($_POST['example'])): // ! represents NOT
        // do something
    endif;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP