HELLO, I HOME THAT HERE SOMEONE CAN BE A MAGICIAN AND WILL HELP ME PLEASE.
IM A NEW IN PHP WORLD AND NEED YOU HELP PLEASE.

I HAVE A DB WITH NAME examen IM CONNECTING TO THIS DB AND THERE ARE A 6 FIELDS

FIELD 1 IS QUESTION
FIELD 2 IS POSSIBLE ANSWER1
FIELD 3 IS POSSIBLE ANSWER2
FIELD 4 IS POSSIBLE ANSWER3
FIELD 5 IS POSSIBLE ANSWER4

FIELD 6 IS A CORRECT ANSWER.IN THE ANSWER FIELDS ARE THE SAME CORRECT ANSWER TOO. PLEASE HELP ME TO CREATE ONE TEST PAGE WHERE THE USER WILL SELECT THE ANSWER AND THEN IT WILL BE COMPARE WITH SELECTION IS TRUE OR NOT.

THANK YOU VERY MUCH

hello try this:

<?
if($_SERVER['REQUEST_METHOD']=='POST')
{
$qry1="SELECT * FROM yourtablename  WHERE correct_answer='".$_POST['ans']."'";
		$res1=mysql_query($qry1) or die(mysql_error());
		$num1=mysql_num_rows($res1);
			if($num1==1)
			{
			echo "correct answer";
			}
			else
			{
			echo "wrong answer!!";
			}
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?
$qry="SELECT * FROM yourtablename  "; 
$res=mysql_query($qry1) or die(mysql_error());
$result=mysql_fetch_array($res);
?>
<form action="" method="post" name="form1">
<table width="100%" border="0">
  <tr>
    <td>1.When of the following is NOT used to test an expression?</td>
  </tr>
  <tr>
    <td><label>
      <input name="ans" type="radio" value="<?=$result['question1']?>" />
    </label>
    A. if ()else statement</td>
  </tr>
  <tr>
    <td><input name="ans" type="radio" value="<?=$result['question1']?>" />
    B. is_double()</td>
  </tr>
  <tr>
    <td><input name="ans" type="radio" value="<?=$result['question1']?>" />
    C. x=y</td>
  </tr>
  <tr>
    <td><input name="isset()" type="radio" value="<?=$result['question1']?>" />
D. isset()</td>
  </tr>
</table>
</form>
</body>
</html>
This article has been dead for over six months. Start a new discussion instead.