PDA

View Full Version : not sure how to do this


AN-net
04-10-2004, 12:31 AM
im using this code:

if($_POST['ques']>1)
{
$fcorrectans= $DB_site->query("SELECT answer,answer_id FROM ".TABLE_PREFIX."quiz_answers WHERE question_id='".$_REQUEST['q']."' AND correct='1'");
while($correctanswer= $DB_site->fetch_array($fcorrectans))
{
if($_POST['ans']==$correctanswer['answer_id'])
{
$correct="1";
}
else
{
$correct="";
}
exec_switch_bg();
eval('$correctansbits .= "' . fetch_template('quiz_correctansbits') . '";');
}
$useranswer= $DB_site->query_first("SELECT answer FROM ".TABLE_PREFIX."quiz_answers WHERE answer_id='".$_POST[ans]."'");
eval('$correctans = "' . fetch_template('quiz_correctans') . '";');
}

it returns correct as 1 if the answer user selected equals the databases answer but since there are multiple answers the second answer shows correct as nothing aka false so it overwrites the first correct. any one know how to avoid this?

Link14716
04-10-2004, 01:05 AM
Just kill the $correct=""; and you should be good to go.

AN-net
04-10-2004, 02:31 AM
thanks