Jump to content

[SOLVED] Posting wrong else echo


kendallkamikaze

Recommended Posts

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

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>";
} 
}
?>

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.