php array to 2d Javascript array
<p>I'm working on passing 2 fields of SQL through php to javascript.  I have read many tutorials on how to create a multidimensional javascript array.  Where I get confused is how to code from php to javascript.  I have seen a couple of tutorials on how to get the php data to javascript, but none on how to do this with 2 dimensions.  </p>

<p>My first hangup is that if I'm creating a multidimensional array I need to count the number of records in my sql data before I declare the java array right? </p>

<p>update:</p>

<p>I got the data to JSON format as suggested below.  Is there a way for me to get all of the contents printed to the web page so that I can see them and then narrow down what is displayed? </p>

<p>update III:</p>

<p>code:</p>

<pre><code>mysql_connect("localhost", "bikemap", "pedalhard") or die(mysql_error()); 
 mysql_select_db("test") or die(mysql_error()); 
 $data = mysql_query("SELECT * FROM gpsdata");
 $new_row = array();
$new_column = array();
 while($info = mysql_fetch_array($data)){

   foreach( $info as $row_num =&gt; $row)
{
      $thisItem = $row;
      $new_row[] = $thisItem;
   }
   array_push($new_column = $new_row);

 }
 $json = json_encode($new_column);
echo $json;    
?&gt;
</code></pre>

<p>Working code:</p>

<pre><code> $data = mysql_query("SELECT * FROM gpsdata");     
$aData = array();
while($row = mysql_fetch_assoc($data))
   $aData[$row['idgpsdata']] = array($row['userID'],$row['date'],$row['lat'], $row['longi'], $row['alt']);


 $json = json_encode($aData);
echo $json;
</code></pre>
