Jump to content

if else statment... was working 5mins ago cant see error


burge124

Recommended Posts

its prob blatant but ive been sat infront of it for so long cant see it. it was working fine 5mins ago!

 

<?php
$con = mysql_connect("localhost","root","")
  or die('Could not connect: ' . mysql_error());
mysql_select_db("questiondb", $con);

$result = mysql_query("SELECT * FROM question WHERE ChapterID='1'");

$user= mysql_fetch_array($result);
?>




<form name="form1" method="post" action="index.php">
  <lable>
  <table width="342" border="1">
    <tr>
      <th width="92" scope="col">ChapterTitle</th>
      <th colspan="2" scope="col"> </th>
    </tr>
    <tr>
      <th scope="row">Question:</th>
      <td colspan="2"><?php echo $user['QuestionTitle']; ?>        <label></label></td>
    </tr>
    <tr>
      <th scope="row">Answer A:</th>
      <td width="193"><?php echo $user['AnswerA']; ?></td>
      <td width="35"><input name="question1" type="radio" value="A"></td>
    </tr>
    <tr>
      <th scope="row">Answer B:</th>
      <td><?php echo $user['AnswerB']; ?></td>
      <td><input name="question1" type="radio" value="B"></td>
    </tr>
    <tr>
      <th scope="row">Answer C:</th>
      <td><?php echo $user['AnswerC']; ?></td>
      <td><input name="question1" type="radio" value="C"></td>
    </tr>
  </table>
  <p>
    <?

$question1 = $_POST['question1'];
?>

<?
if ($question1 == $user['CorrectAnswer'])
{
echo ("<b>Correct</b>");
}
else
{
echo ("<b>Incorrect</b>");
}

?>
  </p>
  <p>
    <label>
    <input type="submit" name="Submit" value="Submit">
    </label>
    <input type="reset" name="Submit2" value="Reset">
  </p>
  </form>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.