Re: ARRAY - straightforward question?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: ARRAY - straightforward question?

From: elyob <newsprofile@gmail.com>
Date: Sun Apr 30 2006 - 20:31:08 CEST

"Jimbus" <mrbiggles909@yahoo.com> wrote in message
news:Y675g.5024$XV5.4781@fed1read10...
> Use an associative array with the coordinates as the key. That way any biz
> that has the same coords will appear under that key in the array.
>
> while($row = mysql_fetch_assoc($result)) {
> $data[ $row['coordinates'] ][] = $row['bizname'];
> }
>
> Note, 'coordinates' and 'bizname' are the db cols, your db col name will
> probably differ from my example.
> Also note second set of empty square braces. These create a new var under
> that key, otherwise you'd just be overwriting the last bizname you saved.

Thanks, my coordinates are currently split into "latitude" and "longitude"
cols, although I will also be soon using the geospatial functionality in
mysql. (Geomotry Point etc).

So, should I be looking to do something like this ... ?

while($row = mysql_fetch_assoc($result)) {
    $data[ $row['longitude'].$row['latitude'] ][] = $row['bizname'];
 }

Thanks
Received on Mon May 1 03:08:02 2006