Re: ARRAY - straightforward question?



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.



.



Relevant Pages

  • Re: what is the best datatype for..
    ... array that will be scanned searching for the index value, ... It also won't be flexible if the input data changes for any reason, since the implementation itself is so dependent on the input data. ... Calling the dictionary solution "inefficient" is just plain dumb; it might not be quite as fast as a straight array lookup, but it's not like it's a _slow_ design. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Beginner Programmer needs help
    ... >> which reliably gets input data. ... Doing user input in a 'foolproof' way is ... question is what state to leave the array in after such an ESC-press ...
    (comp.lang.cpp)
  • Re: Buffer Overflow. What is it?
    ... ]I saw so many buffer overflow attacks on Windows OS. ... How can such event allows an attacker to put a program on the ... area allocated for that array. ... simply copy all the input data given to the routine into that array. ...
    (comp.security.misc)
  • Re: what is the best datatype for..
    ... array that will be scanned searching for the index value, ... It also won't be flexible if the input data changes for any reason, ... difference in performance between using a dictionary and your lookup-array ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Re: Re: RE: Perl Question: Optimization
    ... @ids array changes, the statement gets re-prepared, so unless you have the ... # THIS INPUT DATA FILE CONTAINS ABOUT 40000 ROWS ... >prepared statement inside the loop of 40000. ...
    (perl.dbi.users)