kendallkamikaze Posted April 16, 2009 Share Posted April 16, 2009 Alright so everything in this code is functional...EXCEPT when youre not a status that is mod or diamond. When the status is 'normal' or 'guest' it is supose to display the else portion that says you are not a diamond...except that it is blank...any ideas why? <?php $sql="SELECT * FROM player WHERE id='$id'"; $result=mysql_query($sql); while($r=mysql_fetch_array($result)) { $Status=$r["Status"]; $geneticist=$r["geneticist"]; if ($Status=="mod" || $Status=="Diamond") { if($geneticist=='no') { echo "<td class=tabletd align='center'><span class='page'> <a href='academy_genetics.php'>Take this exam! </a></span></td>"; } else if($geneticist=='yes') { echo "<td class=tabletd align='center'><span class='page'> <font size='2px'>You've already passed this exam!</font></span></td>"; } else { echo "<td class=tabletd align='center'><span class='page'> You have to be a Diamond in order to take this exam.</span></td>"; } } } ?> Link to comment https://forums.phpfreaks.com/topic/154278-solved-posting-wrong-else-echo/ Share on other sites More sharing options...
JD* Posted April 16, 2009 Share Posted April 16, 2009 Because your check is inside of the diamond check...change it to this: <?php $sql="SELECT * FROM player WHERE id='$id'"; $result=mysql_query($sql); while($r=mysql_fetch_array($result)) { $Status=$r["Status"]; $geneticist=$r["geneticist"]; if ($Status=="mod" || $Status=="Diamond") { if($geneticist=='no') { echo "<td class=tabletd align='center'> <span class='page'> <a href='academy_genetics.php'>Take this exam! </a></span></td>"; } else if($geneticist=='yes') { echo "<td class=tabletd align='center'><span class='page'> <font size='2px'>You've already passed this exam!</font></span></td>"; } } else { echo "<td class=tabletd align='center'><span class='page'> You have to be a Diamond in order to take this exam.</span></td>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/154278-solved-posting-wrong-else-echo/#findComment-811078 Share on other sites More sharing options...
mrMarcus Posted April 16, 2009 Share Posted April 16, 2009 you don't have an else statement for what you are asking. check again. that's why indenting helps. Link to comment https://forums.phpfreaks.com/topic/154278-solved-posting-wrong-else-echo/#findComment-811079 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.