Results 1 to 6 of 6
August 25th, 2007, 07:44 PM #1PHP question about NOT ISNULL() condition
I'm really stretching the bounds of my meager PHP knowledge here. But here goes:
I'm displaying products from a very large datafeed I have in a MySQL table. Within the table is a field of images for each item in the datafeed, which is named "BigImage." BUT -- in this particular datafeed, there are lots of items with no BigImage available.
How would I structure the SELECT command to display products with a given "Name" condition, yet ONLY display those products with BigImages? I googled around and came up with this:
$query = "SELECT Name, Description, Link, BigImage FROM table where NOT ISNULL(BigImage) and Name like '%xxxxx%' ORDER BY RAND()";
That selects products and later in the script I have echo statements to create a table on my web page that displays what has been selected -- BUT, it displays everything that matches the "Name" condition (like '%xxxxx%'), and ignores the NOT ISNULL(BigImage) condition completely.
In other words, this "solution" doesn't work for me -- it continues to display lots of items that lack images.
Comments? Solutions?? HELP!!!!
ThanksGenerate more fake news.
August 25th, 2007, 07:56 PM #2
Testing for NULL values in all kinds of code can be tricky sometimes, simply b/c NULL doesn't always mean "empty". Give this a shot instead:
$query = "SELECT Name, Description, Link, BigImage FROM table where BigImage != "" AND Name like '%xxxxx%' ORDER BY RAND()";
Hope that works for you.
August 25th, 2007, 08:27 PM #3Originally Posted by MoneyBusiness
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/xxxxx/public_html/xxxxx.php on line 11
But with the single quote marks it does the trick. So do I get an error with the double quote marks?Generate more fake news.
August 25th, 2007, 08:42 PM #4
FWIW, this is really a MySQL question rather than a PHP question.
$query = "SELECT Name, Description, Link, BigImage FROM table where BigImage is not null and Name like '%xxxxx%' ORDER BY RAND()";
August 25th, 2007, 08:51 PM #5Originally Posted by writerguy
Anyway, good to hear it works!
August 26th, 2007, 01:41 AM #6Originally Posted by adambhaGenerate more fake news.
By teezone in forum Programming / Datafeeds / ToolsReplies: 8Last Post: September 4th, 2009, 04:54 PM
By mopek in forum Programming / Datafeeds / ToolsReplies: 4Last Post: August 23rd, 2006, 04:51 PM
By Doug247 in forum Programming / Datafeeds / ToolsReplies: 1Last Post: March 31st, 2004, 10:20 AM
By ~Michelle in forum Programming / Datafeeds / ToolsReplies: 12Last Post: March 18th, 2004, 02:52 PM