我正在尝试构建php在线考试页面,我已将所有数据保存在表格中
现在我想在浏览器中显示问题和答案选项 我尝试了以下操作,但不起作用
<html>
<head>
<title> Exam Paper </title>
</head>
<body>
<?php $ecourse_id = '3';
sc_select(questions_data,"select equestion_id,question,correct_option,marks_allocated,option_1,option_2,option_3,option_4 from sri_dev_mob.cms_elearning_questions where ecourse_id='$ecourse_id'");
$count = {questions_data}->RecordCount();
if($count>0)
{
$seq = 1;
foreach($questions_data as $record){
extract($record);
echo $seq.')'.$question."<br>";
echo "<input type='radio' name='$seq' value='$option_1'>".$option_1."<br>";
echo "<input type='radio' name='$seq' value='$option_2'>".$option_2."<br>";
echo "<input type='radio' name='$seq' value='$option_3'>".$option_3."<br>";
echo "<input type='radio' name='$seq' value='$option_4'>$option_4 <br>";
$seq++;
}
}
?>
</body>
</html>
答案 0 :(得分:1)
请尝试以下解决方案
使用 htmlspecialchars()函数
echo "<input type='radio' name='$seq' value='$option_1'>".htmlspecialchars($option_1)."<br>";