问题描述
我的代码似乎不起作用..单选按钮出现了,但是旁边没有任何东西..好像mysql_fetch_array由于某种原因无法正常工作,因为我已经玩过代码并反复测试以查找代码的位置似乎遇到问题并停止工作..有人可以请教出什么问题吗?欢呼声我是新来的,最近几天才完成在w3schools上学习php教程.
my code doesnt seem to work.. the radio buttons appear but nothing beside them .. it seems as if the mysql_fetch_array is not working for some reason as i have played about with the code and repeatedly tested it to find where the code seems to encounter a problem and stop working.. could someone please advise what is wrong? cheers ps. i am new at this, only finished learning the php tutorial on w3schools last few days.
<body>
<?php
include 'dbyear2.php';
$qnumber = $_REQUEST['uqn']; // obtain question number from URL
$find = mysql_query("SELECT * FROM Renal WHERE UQN='$qnumber'");
while($retrieve=mysql_fetch_array($find));
{
$retrieve['question'] = $question;
$retrieve['MCQ_A'] = $a;
$retrieve['MCQ_B'] = $b;
$retrieve['MCQ_C'] = $c;
$retrieve['MCQ_D'] = $d;
$retrieve['MCQ_E'] = $e;
$retrieve['answer'] = $answer;
$retrieve['MCQ_correct'] = $correct;
}
?>
<form action='check.php' method='POST'>
<table>
<tr><td></td><td></td></tr>
<tr></tr>
<tr><td><input type='radio' name='group1' value='A' /></td><td> <?php echo $a; ?></td></tr>
<tr><td><input type='radio' name='group1' value='B' /></td><td> <?php echo $b; ?></td></tr>
<tr><td><input type='radio' name='group1' value='C' /></td><td> <?php echo $c; ?></td></tr>
<tr><td><input type='radio' name='group1' value='D' /></td><td> <?php echo $d; ?></td></tr>
<tr><td><input type='radio' name='group1' value='E' /></td><td> <?php echo $e; ?></td></tr>
<tr>
<?php
// sending the retrieved information from MYSQL via POST for use in check.php file
$qnumber;
$a;
$b;
$c;
$d;
$e;
$answer;
$correct;
?></tr>
<tr><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</body>
</html>
推荐答案
此部分向后:
$retrieve['question'] = $question;
$retrieve['MCQ_A'] = $a;
$retrieve['MCQ_B'] = $b;
$retrieve['MCQ_C'] = $c;
$retrieve['MCQ_D'] = $d;
$retrieve['MCQ_E'] = $e;
$retrieve['answer'] = $answer;
$retrieve['MCQ_correct'] = $correct;
应该是
$question = $retrieve['question' ;
$a = $retrieve['MCQ_A'];
$b = $retrieve['MCQ_B'];
$c = $retrieve['MCQ_C'];
$d = $retrieve['MCQ_D'];
$e = $retrieve['MCQ_E'];
$answer = $retrieve['answer'];
$correct $retrieve['MCQ_correct'];
请不要在新代码中使用mysql_*
函数.它们已不再维护并已正式弃用.看到红色框?了解有关 准备好的语句 的信息,并使用 PDO 或 MySQLi -本文将帮助您确定哪一个.如果您选择PDO,这里是一个很好的教程.
Please, don't use mysql_*
functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.
您还广泛接受 SQL注入
You are also wide open to SQL injections
您不应使用 w3schools .它不是可靠的信息来源,我们也不想鼓励人们使用它.
You should not use w3schools. It's not a reliable source of information and we don't want to encourage its use.
这篇关于PHP的回声无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!