Run query inside a loop statement
Posted: Wed Jun 30, 2010 1:47 pm
Basically what I am trying to do is this. I have results that I am fetching from a query and displaying on my site. I want to be able to take one of the results from that query and do another query on a seperate table for results that will be displayed in the same loop.
What I have:
What I want:
I hope I am not asking the impossible and have made it clear what I am looking for. Thank you in advance for any help.
What I have:
Code: Select all
while($searchrow = mysql_fetch_array($searchresult)){
$business_id = $searchrow['business_id'];
}Code: Select all
while($searchrow = mysql_fetch_array($searchresult)){
$business_id = $searchrow['business_id'];
$bizsearch = mysql_query("SELECT * FROM businesses WHERE business_id='$business_id'");
while($bizrow = mysql_fetch_array($bizsearch)){
$business_name = $bizrow['business_name'];
$business_phone = $bizrow['business_phone'];
}