Using PHP, for-each row in a MySQL query's result set, I need to execute another MySQL query. So far, I've got
$result = mysql_query("SELECT id, state FROM states WHERE region='given_region'")
or die(mysql_error());
while($row = mysql_fetch_row($result))
{
$state = $row['state'];
$r = mysql_query("SELECT * FROM locations WHERE state REGEXP '(^|,)".$state."($|,)'");
}
Now I need to append all of the results $r into ONE result set that I can then iterate through with a standard while-loop, however, my very limited PHP skills are leaving me at a loss getting code to do that.
Can anyone provide any insight into how I'd go about appending all the results into one set within the given while loop?
Thanks!