noirsith Posted July 25, 2008 Share Posted July 25, 2008 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 More sharing options...
ranjuvs Posted July 25, 2008 Share Posted July 25, 2008 remove the exit(); function Link to comment https://forums.phpfreaks.com/topic/116618-mutually-exclusive-if-else-statements/#findComment-599617 Share on other sites More sharing options...
noirsith Posted July 25, 2008 Author Share Posted July 25, 2008 Thank you much, I'm a moron. Link to comment https://forums.phpfreaks.com/topic/116618-mutually-exclusive-if-else-statements/#findComment-599626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.