Jump to content

Mutually exclusive IF ELSE statements


noirsith

Recommended Posts

I'm trying to run mutually exclusive if else statements in php but for some reason it stops after the first one. I'm trying to check if the answers to a test are right or wrong using the following code, but it only gives me the result for the first one.

 

Also is there a better way to check whether the answers stored in a table for a test are correct.

 

Thank you much!

 

Below is the code if it helps for the first two statements.

 

$q1 = mysql_query("SELECT * FROM GrammarAnswers where lname = '$Lastname'");
$ques1 = mysql_result($q1,0,0);

IF ($ques1="is")
{
echo "1. Correct";
exit();
}
ELSE 
{
echo "1. Wrong";
}

echo "<br/>";

echo "hello";

$q2 = mysql_query("SELECT * FROM GrammarAnswers where lname = '$Lastname'");
$ques2 = mysql_result($q2,0,0);

IF ($ques2="aren't")
{
echo "2. Correct";
exit();
}
ELSE 
{
echo "2. Wrong";
}

echo "<br/>";

Link to comment
https://forums.phpfreaks.com/topic/116618-mutually-exclusive-if-else-statements/
Share on other sites

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.