如何在答案正确时显示答案正确的消息??这是我的尝试>我试图做出(if),但当答案正确时返回false>>如何解决此问题请帮忙!!!
<table dir="rtl"style="margin-right: 10px;" id="rounded-corner" summary="2007 Major IT Companies' Profit" style="margin-left:150px;">
<thead>
</thead>
<tbody>
<?php
$query_run=mysql_query("select * from questions ORDER BY RAND() LIMIT 5");
while($row=mysql_fetch_array($query_run))
{
$question = $row['question'];
$ans = $row['ans'];
$anstwo = $row['anstwo'];
$correct_ans = $row['correct_ans'];
?>
<tr>
<th colspan="3"width="211" class="rounded" scope="col">السؤال</th>
</tr>
<tr>
<?php
echo"<tr><td> <img src=question/$question width=100 hieght=100></td></tr>";
echo"<tr><td><label>
<input type='"radio'" name='"fb'" value='"small'" /><img src=question/$ans width=100 hieght=100></label></td><td><label>
<input type='"radio'" name='"fb'" value='"small'" /><img src=question/$anstwo width=100 hieght=100></label></td><td><label>
<input type='"radio'" name='"fb'" value='"$correct_ans'" /><img src=question/$correct_ans width=100 hieght=100></label></td</tr><br>";
?>
</tr>
<?php
}
if (isset($_POST['submit'])) {
$value = $_POST;
if ($value == "$correct_ans")
echo "THAT ANSWER IS CORRECT";
else
echo "THAT ANSWER IS WRONG!";}
?>
</tbody>
</table>
if ($value == "$correct_ans")
echo "THAT ANSWER IS CORRECT";
else
echo "THAT ANSWER IS WRONG!";}
应该是
if ($value == $correct_ans)
{
echo "THAT ANSWER IS CORRECT";
}else
{
echo "THAT ANSWER IS WRONG!";
}
您发布的"$correct_ans"是一个字符串,而不是变量。