Re: ARRAY - straightforward question?
- From: "Jimbus" <mrbiggles909@xxxxxxxxx>
- Date: Sun, 30 Apr 2006 11:16:09 -0700
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.
"elyob" <newsprofile@xxxxxxxxx> wrote in message
news:4454f07a$1@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
I've got a database that outputs markers on a google map project. The
problem I am encountering is that some businesses have been located the
same latitude and longitude, therefore markers don't show (others are
underneath the top one). So, I need to get this MySQL output, parse it
through an array creating an output such as
(-0.28183499,51.37974167), biz1 biz2 biz3
(-0.28301400,51.38087463), biz4
(-0.28151301,51.38144684), biz5
(-0.28693399,51.38250351), biz6
(-0.28626299,51.38276672), biz7
(-0.29334599,51.38436890), biz8 biz9 biz10
(-0.29725999,51.38850021), biz11 biz12
(-0.29800400,51.38896179), biz13 biz14
Here's an example of my input data as it is at the moment ..
(-0.28183499,51.37974167), biz1
(-0.28183499,51.37974167), biz2
(-0.28183499,51.37974167), biz3
(-0.28301400,51.38087463), biz4
(-0.28151301,51.38144684), biz5
(-0.28693399,51.38250351), biz6
(-0.28626299,51.38276672), biz7
(-0.29334599,51.38436890), biz8
(-0.29334599,51.38436890), biz9
(-0.29334599,51.38436890), biz10
(-0.29725999,51.38850021), biz11
(-0.29725999,51.38850021), biz12
(-0.29800400,51.38896179), biz13
(-0.29800400,51.38896179), biz14
I already sort the data by latitude, so they will always be next to each
other. But I am going to be writing this using AJAX and need the fastest
solution possible. There could be hundreds needed to be parsed in a split
second.
Thanks for any pointers.
.
- Follow-Ups:
- Re: ARRAY - straightforward question?
- From: elyob
- Re: ARRAY - straightforward question?
- References:
- ARRAY - straightforward question?
- From: elyob
- ARRAY - straightforward question?
- Prev by Date: Re: Validating form input data
- Next by Date: Re: ARRAY - straightforward question?
- Previous by thread: ARRAY - straightforward question?
- Next by thread: Re: ARRAY - straightforward question?
- Index(es):
Relevant Pages
|