Jim R Posted October 8, 2010 Share Posted October 8, 2010 I have a column in my MySQL database "paid". I have values of p for PayPal, c for check, and f for free. Those who haven't paid the record is marked (NULL). Right now my code is: if ($line['paid'] == 'y') { echo '.</center></td>';} else { echo '</center></td>';} That works pretty well for when I was just using those who paid vs. those who didn't. However, I'm wanting my site to show who has paid vs. those who haven't, while my data table will easily show how they paid. I either need an array or I need to reverse the IF...ELSE to say IF it's NULL do nothing, ELSE mark paid. Quote Link to comment https://forums.phpfreaks.com/topic/215394-ifelse-syntax-using-null-values/ Share on other sites More sharing options...
Pikachu2000 Posted October 8, 2010 Share Posted October 8, 2010 Check it against an array of values. $paid = array('p', 'c', 'f'); if( in_array($line['paid'], $paid) ) { // marked as paid } else { //not marked as paid } Quote Link to comment https://forums.phpfreaks.com/topic/215394-ifelse-syntax-using-null-values/#findComment-1120084 Share on other sites More sharing options...
Jim R Posted October 8, 2010 Author Share Posted October 8, 2010 Thanks. That did the trick. Clearly I haven't had much experience with arrays either. Quote Link to comment https://forums.phpfreaks.com/topic/215394-ifelse-syntax-using-null-values/#findComment-1120085 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.