suess0r Posted December 28, 2006 Share Posted December 28, 2006 Hi, my table is set so if the field isn't filled out it's set as NULL, i want to only print out the records that aren't = to "NULL" but it prints out all of them and not just the ones that that have info in them and aren't = to NULL...[quote]if (mysql_result($result_set, $i, "NS_Mon") != "NULL") { $NSmon=mysql_result($result_set, $i, "NS_Mon"); echo'<br><b>Mon: </b>'.$NSmon.''; } else { echo'<br><b>No Specials Provided.</b>'; $NSmon="None"; } if (mysql_result($result_set, $i, "NS_Tues") != "NULL") { $NStues=mysql_result($result_set, $i, "NS_Tues"); echo'<br><b>Tue: </b>'.$NStues.''; } else { $NStues="None"; } if (mysql_result($result_set, $i, "NS_Wed") != "NULL") { $NSwed=mysql_result($result_set, $i, "NS_Wed"); echo'<br><b>Wed: </b>'.$NSwed.''; } else { $NSwed="None"; } if (mysql_result($result_set, $i, "NS_Thur") != "NULL") { $NSthur=mysql_result($result_set, $i, "NS_Thur"); echo'<br><b>Thr: </b>'.$NSthur.''; } else { $NSthur="None"; } if (mysql_result($result_set, $i, "NS_Fri") != "NULL") { $NSfri=mysql_result($result_set, $i, "NS_Fri"); echo'<br><b>Fri: </b>'.$NSfri.''; } else { $NSfri="None"; } if (mysql_result($result_set, $i, "NS_Sat") != "NULL") { $NSsat=mysql_result($result_set, $i, "NS_Sat"); echo'<br><b>Sat: </b>'.$NSsat.''; } else { $NSsat="None"; } if (mysql_result($result_set, $i, "NS_Sun") != "NULL") { $NSsun=mysql_result($result_set, $i, "NS_Sun"); echo'<br><b>Sun: </b>'.$NSsun.''; } else { $NSsun="None"; }[/quote] Quote Link to comment Share on other sites More sharing options...
craygo Posted December 28, 2006 Share Posted December 28, 2006 Should just do it with the sql statement[code]$sql = "SELECT * FROM table WHERE field IS NOT NULL";[/code]Also in php if you put single quotes around 'NULL' it is actually looking for the word NULL. Just use NULL without any quotes.[code]if (mysql_result($result_set, $i, "NS_Mon") != NULL)[/code]Ray 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.