繁体   English   中英

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

[英]Why is my data not being displayed?

我有一个带有单选按钮的页面,提交后应该显示到quiz_layout.php页面。 布局页面仅应基于提交的单选按钮显示测验。 谁能帮我? 我不确定为什么不显示我的数据。

第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>"; 

提交后,它应根据所选的单选按钮显示我的测验

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>

quiz_layout.php被设置为一次显示一个问题,但什么都没有显示。 帮忙,谢谢你

您是否检查了查询结果或查询中的条件(WHERE $ table.quiz_name ='$ name')? “ $ name”已设置或未选中。

您的html无效,您忘记了属性值中的引号。 替换所有的html代码,如下所示。

echo "<form action=\"/xampp/Website_DataBase/Pvamu_website/quiz/index.php\" method=\"post\">";

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM