Re: ARRAY - straightforward question?
- From: "elyob" <newsprofile@xxxxxxxxx>
- Date: Sun, 30 Apr 2006 19:31:08 +0100
"Jimbus" <mrbiggles909@xxxxxxxxx> wrote in message
news:Y675g.5024$XV5.4781@xxxxxxxxxxxxx
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
.
- References:
- ARRAY - straightforward question?
- From: elyob
- Re: ARRAY - straightforward question?
- From: Jimbus
- ARRAY - straightforward question?
- Prev by Date: Re: ARRAY - straightforward question?
- Next by Date: Which database extension? PDO or DB or ODBC?
- Previous by thread: Re: ARRAY - straightforward question?
- Next by thread: Which database extension? PDO or DB or ODBC?
- Index(es):
Relevant Pages
|