Jump to content

[SOLVED] If row NULL in query ignore?


SEVIZ

Recommended Posts

This should be working.  Its something I actually had tried before but the option still shows.  Here is my full code in case its needed for something else I am missing.

 

<?php 

$q = "SELECT `sup` FROM `sprint` WHERE `sup` IS NOT NULL GROUP BY `sup`";
$ret = mysql_query($q);

while ($row = mysql_fetch_assoc($ret)) {
    $email_sec = $row['sup'];
    print "<option value=\"$email_sec\">Team $email_sec</option>";
}
?>

how did those rows in `sup` get to be null in the first place?  do you have it set as the default and when you insert a new row, leave that column blank?  when you insert a new row, are you doing null or 'null' if you are putting something?

 

point I'm trying to make is, maybe it's not really NULL but is storing a string of value "NULL" or an empty string "" (which is not the same as null), due to however you have your db or code setup.

how did those rows in `sup` get to be null in the first place?  do you have it set as the default and when you insert a new row, leave that column blank?  when you insert a new row, are you doing null or 'null' if you are putting something?

 

There are only two items that are empty in this spot.  I imported all the data from an excel sheet originally.  In phpmyadmin this is set as "not null" with no default set if that matters.

okay well if you have it set to be "not null" then they are not null, and that's why your query isn't working the way you want.  You need to change the condition to something else like ..where `sup` != '' or ..where length(`sup`) > 0

 

 

edit:

 

ah okay cool.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.