I am trying to take an array list of product ids, get the associated data (which is stored in another table, I know… that is poorly set up), and then alphabetize them based on the product name. Here is what I have thus far:
$set = array($aID['id']);
$getInfo = mysql_query("SELECT * FROM tbl WHERE FIND_IN_SET('$set', id) ORDER BY name ASC");
while($product = mysql_fetch_array($getInfo))
{
echo $product['name'] . " <br /\n";
}
I am getting an error message for the while row which means something is wrong on my $getInfo query line. What am I doing wrong? Any help and all constructive criticism is appreciated.
You can’t pass an array into mysql. You need to convert it to a comma seperated string:
Also the order is reversed in your FIND_IN_SET. It should be
Honestly, I’d just use
INas FIND_IN_SET returns an index of where it is in the set, not probably what you want: