jaxdevil Posted November 5, 2007 Share Posted November 5, 2007 I am trying to display one thing if a customer has paid and is tax exempt, something else if they paid and are not tax exempt, and something else all together if they have not paid. Here is what I am trying now, but it always displays 'error' , like it is not finding either of the other statements. Here is the code I am using.... if($row['paid'] == "yes" && $row['exempt'] == "1") {echo "" .$sum2;} else if ($row['paid'] == "yes" && $row['exempt'] == "0") {echo "" .$sum4;} else if ($row['paid']=="no") {echo "UNPAID";} else {echo "error";} Anyone see where I am going wrong? Link to comment https://forums.phpfreaks.com/topic/76084-problem-with-if-and-else-if-statement/ Share on other sites More sharing options...
kenrbnsn Posted November 5, 2007 Share Posted November 5, 2007 Try restructuring your "if" block: <?php if ($row['paid'] == 'yes') if ($row['exempt'] == '1') echo $sum2; if ($row['exempt'] == '0') echo $sum4; elseif ($row['paid'] == 'no') echo 'UNPAID'; else echo 'error'; ?> or use a "switch" block: <?php switch ($row['paid']) { case 'yes': if ($row['exempt'] == '1') echo $sum2; if ($row['exempt'] == '0') echo $sum4; break; case 'no': echo 'UNPAID'; break; default: echo 'error'; }?> Ken Link to comment https://forums.phpfreaks.com/topic/76084-problem-with-if-and-else-if-statement/#findComment-385151 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.