Re: ARRAY - straightforward question?




"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


.



Relevant Pages

  • Re: [/QUIZ] #63: Grid Folding
    ... last element gives the fold direction. ... first part of the array. ... def initialize(values, rows, cols) ...
    (comp.lang.ruby)
  • how does your language... make a map?
    ... "include"ed in the interpreter for testing. ... Since Forth uses a Last-in-First-out implicit stack, ... variable cols ... I want to create an array that will in the future contain all the ...
    (rec.games.roguelike.development)
  • Re: opposite of zip()?
    ... from array import array ... def f1(recs, cols): ... for r in recs: ...
    (comp.lang.python)
  • Re: Import .txt file into matlab
    ... i del the date & time, store the cols in an array & also convert the ... does what you need for inputting. ...
    (comp.soft-sys.matlab)
  • Re: [QUIZ][SOLUTION] Grid Folding (#63)
    ... Made check_fold not copy the array and instead just index into the array passed. ... Throws ArgumentError on invalid direction or rows or cols # not a power of 2. ... def check_fold ... raise ArgumentError, "Paper not completely folded" ...
    (comp.lang.ruby)