PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I found this sample code a couple of places. I'm having a hard time seeing where the results are applied to a variable. All I get is echoed/printed results. Is there a $var in this code that holds the values that I'm seeing printed after running in a browser?
$agents = array();
If ($result = mysql_query("SELECT h.title, h.address, a.agentname
FROM homes h, agents a WHERE
h.owner=a.id AND a.id=$aid"))
{ while ($array = mysql_fetch_array($result))
{ $agents[$array["agentname"]][] = $array;
}
}
foreach($agents as $agent=>$addresses)
{ echo("$agent<br>");
foreach($addresses as $address)
{ echo("{$address["title"]}, {$address["address"]}");
}
}
Last edited by mcwdes on Wed Jan 07, 2009 11:41 am, edited 2 times in total.
Hey papa,
Yes... I understand that part... and can do that with much more simplified code. I found this code while looking for a way to have a simple variable, not an array, be equal to the results of a loop statement. I know its possible, just can't figure it out.
To all... the topic code was an attempt to store structured code including query results in a $var in order to fwrite to a file. Silly me, turns out I can loop the fwrite function. Sorry if I wasted anyones time with this.