Re: Selecting Rows Based on Row Values Being in Array

From: Date: Wed, 04 Jul 2007 03:51:55 +0000
Subject: Re: Selecting Rows Based on Row Values Being in Array
References: 1 2 3 4 5 6 7 8 9  Groups: php.general 
Request: Send a blank email to php-general+get-258218@lists.php.net to get a copy of this message
kvigor wrote:
Jim, Thanks for all you help. Tell me where to mail you the check "seriously". If we get this right I'll owe you. OK, the query string now looks like you said it would. However Query isn't returning a match. //DETAILS========================================================= My $list array looks like this one echo'd: $list[0] =7orange50lbs $list[1] =8purple60lbs Now when I do this: $query_One= "SELECT * FROM shoe WHERE CONCAT(size,color,weight) IN({$in_list})"; $result = mysql_query($query_One,$connection) or die("Query failed: ". mysql_error($connection)); $row = mysql_fetch_assoc($result); while($row = mysql_fetch_assoc($result))
This should be: $result = mysql_query($query_One,$connection) or die("Query failed: ". mysql_error($connection)); while($row = mysql_fetch_assoc($result)) .... Otherwise you're ignoring the first result every time (note I removed the first $row = mysql_fetch_assoc($result)). Does the query work in mysql itself? Echo it out and run it manually in phpmyadmin or something to make sure it does return what you need and doesn't produce an empty result set. -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.general (#258218) next »