gw32 Posted August 21, 2011 Share Posted August 21, 2011 This is probably easy but I can't get it. I have code like this: if ($sta == "A") { echo "<P><font size='+2' color='yellow'>Approved Charities</font></P>"; } elseif ($sta == "C") { echo "<P><font size='+2' color='yellow'>Contacted Charities</font></P>"; } elseif ($sta == "D") { echo "<P><font size='+2' color='yellow'>Declined Charities</font></P>"; } elseif ($sta == "S") { echo "<P><font size='+2' color='yellow'>Submitted Charities</font></P>"; } elseif ($sta == "CB") { echo "<P><font size='+2' color='yellow'>Call Back Charities</font></P>"; } elseif ($sta == "AP") { echo "<P><font size='+2' color='yellow'>Appointments with Charities</font></P>"; } elseif ($sta == "") { echo "<P><font size='+2' color='yellow'>All Charities</font></P>"; } Now I want to display only the rows that do not contain (A, C, D, S, CB, AP). Any help would be appreciated. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/245379-if-and-esleif-statement/ Share on other sites More sharing options...
$php_mysql$ Posted August 21, 2011 Share Posted August 21, 2011 maybe this? if ($sta == "A") { echo "<P><font size='+2' color='yellow'>Approved Charities</font></P>"; } elseif ($sta == "C") { echo "<P><font size='+2' color='yellow'>Contacted Charities</font></P>"; } elseif ($sta == "D") { echo "<P><font size='+2' color='yellow'>Declined Charities</font></P>"; } elseif ($sta == "S") { echo "<P><font size='+2' color='yellow'>Submitted Charities</font></P>"; } elseif ($sta == "CB") { echo "<P><font size='+2' color='yellow'>Call Back Charities</font></P>"; } elseif ($sta == "AP") { echo "<P><font size='+2' color='yellow'>Appointments with Charities</font></P>"; }else{ echo "<P><font size='+2' color='yellow'>All Charities</font></P>"; } or maybe you can try not equal to (!$sta == "AP") Quote Link to comment https://forums.phpfreaks.com/topic/245379-if-and-esleif-statement/#findComment-1260286 Share on other sites More sharing options...
voip03 Posted August 21, 2011 Share Posted August 21, 2011 use switch http://php.net/manual/en/control-structures.switch.php Quote Link to comment https://forums.phpfreaks.com/topic/245379-if-and-esleif-statement/#findComment-1260292 Share on other sites More sharing options...
cunoodle2 Posted August 22, 2011 Share Posted August 22, 2011 I second voip03 recommendation. I too would use a switch statement. It is exactly what you need. Quote Link to comment https://forums.phpfreaks.com/topic/245379-if-and-esleif-statement/#findComment-1260481 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.