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? Quote Link to comment 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 Quote Link to comment 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.