Please help! I am trying to write a page that creates a customized search on MySQL table. In short I need to include NULL values in the search results, but not for those records that have a value entered. (Sound confusing? It is to me!)
if ($program =="")
{$program ='%';}
if ($customer =="")
{$customer ='%';}
if ($prefix =="")
{$prefix ='%';}
etc. - five more lines of testing. This is so that if they fill in a product number it will still match all customers with that product number.
Then I have:
$result= mysql_query ("SELECT * from table WHERE Program LIKE '$program%' AND Customer LIKE '$customer%' AND Prefix LIKE '$prefix%' ...)
The problem is when one of the records has a NULL value in a field, it doesn't get included in the recordset. If I just search for Program 123, If one of those Programs doesn't have a Prefix (the Prefix field can and will be NULL on occasion) then it doesn't show up the the results.
Does anyone know how I can fix this?
Thanks.
if ($program =="")
{$program ='%';}
if ($customer =="")
{$customer ='%';}
if ($prefix =="")
{$prefix ='%';}
etc. - five more lines of testing. This is so that if they fill in a product number it will still match all customers with that product number.
Then I have:
$result= mysql_query ("SELECT * from table WHERE Program LIKE '$program%' AND Customer LIKE '$customer%' AND Prefix LIKE '$prefix%' ...)
The problem is when one of the records has a NULL value in a field, it doesn't get included in the recordset. If I just search for Program 123, If one of those Programs doesn't have a Prefix (the Prefix field can and will be NULL on occasion) then it doesn't show up the the results.
Does anyone know how I can fix this?
Thanks.