I am retrieving results from a query and trying to insert them into a second query.. $sqlstring3 = "SELECT ///// "; $result2 = mysql_query($sqlstring3); while ($row = mysql_fetch_array($result2, MYSQL_ASSOC)) { $strquery .= " ".$row["numbers"].", "; } mysql_free_result($result2); PHP: that code does this 213, 321, 123, 221, 321, which is great but how do insert that into the next query? I am currently doing this. $query = "select * from ??? where number IN (".$strquery.") order by Value"; PHP: the problem is it gives me this result. $query = "select * from ??? where number IN (213, 321, 123, 221, 321, ) order by Value"; PHP: which does not work.. I need to end the query with a 321) not a 321, ) any help on how to alter this while ($row = mysql_fetch_array($result2, MYSQL_ASSOC)) { $strquery .= " ".$row["numbers"].", "; } PHP: to get the last value to do 321) not a 321, )???
you can do so with the implode function of php. more details about it can be found in the documentation. Cheers.