dpmfur2635 2014-04-12 18:43
浏览 12
已采纳

为什么我的数据没有显示?

I have a page with radio buttons and when submitted it should display go to a quiz_layout.php page. The layout page is should display a quiz only based on the radio button submitted. Can anyone help me? I'm not sure why my data isn't being displayed.

page 1: quiz_main.php

//form for selecting quiz
echo "<form action=/xampp/Website_DataBase/Pvamu_website/quiz/index.php method=post>";
$mysql = "SELECT DISTINCT quiz_name FROM $table";
$mydata = mysql_query($mysql,$con);
while($records = mysql_fetch_array($mydata)){
    $quizname=$records['quiz_name'];

    echo "<input type=radio name=name_quiz value=".$records['quiz_name'].">".$records['quiz_name']."<br>";
}
echo "<input type=submit value=Submit Continue>";
echo "</form>"; 

Once submitted it should display my quiz based on the selected radio button

quiz_layout.php

$name = '';
if ( !empty( $_POST['name_quiz'] ) && $_POST['name_quiz'] != '' ) {
    $name = $_POST['name_quiz'];
}

$resource = "SELECT * FROM $table WHERE $table.quiz_name = '$name'";

$mydata=mysql_query($resource);

while($result=mysql_fetch_array($mydata)){
     ?>
<div id="question_<?php echo $result['id'];?>" class='questions'>
<h2 id="question_<?php echo $result['id'];?>"><?php echo $result['id'].".".$result['question_name'];?></h2>
<div class='align'>
<input type="radio" value="1" id='radio1_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'>
<label id='ans1_<?php echo $result['id'];?>' for='1'><?php echo $result['answer1'];?></label>
<br/>
<input type="radio" value="2" id='radio2_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'>
<label id='ans2_<?php echo $result['id'];?>' for='1'><?php echo $result['answer2'];?></label>
<br/>
<input type="radio" value="3" id='radio3_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'>
<label id='ans3_<?php echo $result['id'];?>' for='1'><?php echo $result['answer3'];?></label>
<br/>
<input type="radio" value="4" id='radio4_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'>
<label id='ans4_<?php echo $result['id'];?>' for='1'><?php echo $result['answer4'];?></label>
<input type="radio" checked='checked' value="5" style='display:none' id='radio4_<?php echo $result['id'];?>' name='<?php echo $result['id'];?>'>
</div>
<br/>
<input type="button" id='next<?php echo $result['id'];?>' value='Next!' name='question' class='butt'/>
</div>
<?php }?>
</form>

The quiz_layout.php is setup to display one question at a time but nothing is displaying. Help and thank you

  • 写回答

2条回答 默认 最新

  • duankui6150 2014-04-12 18:58
    关注

    Have you checked your query result or where condition in query(WHERE $table.quiz_name = '$name')? "$name" is set or not checked it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 php 将rtmp协议转hls协议,无法播放
  • ¥15 miniconda安装不了
  • ¥20 python代码编写
  • ¥20 使用MPI广播数据遇到阻塞
  • ¥15 TinyMCE如何去掉自动弹出的“链接…”工具?
  • ¥15 微信支付转账凭证,如何解决
  • ¥15 在win10下使用指纹登录时,界面上的文字最后一个字产生换行现象
  • ¥20 使用AT89C51微控制器和MAX7219驱动器来实现0到99秒的秒表计数,有开始和暂停以及复位功能,下面有仿真图,请根据仿真图来设计c语言程序
  • ¥15 51单片机 双路ad同步采样
  • ¥15 使用xdocreport 生成word