dpwhite Posted September 14, 2008 Share Posted September 14, 2008 I just want to take an entire row from the DB and put it in a 2D array. Thanks Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 14, 2008 Share Posted September 14, 2008 Not enough information provided for a meaningful answer. Please explain yourself better. Ken Quote Link to comment Share on other sites More sharing options...
dpwhite Posted September 14, 2008 Author Share Posted September 14, 2008 $reeadings is a associative array function getdata1() { $stmt1= "select * from latlonreadings"; $results = mysql_query($stmt1); $line=1; while (($row = mysql_fetch_object($results))) { $readings[$line]=array($row); #### this line is wrong it fills array but includes more than values(i.e. lat=>12.123456) $line=$line+1; } Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 14, 2008 Share Posted September 14, 2008 Try: <?php function getdata1() { $stmt1= "select * from latlonreadings"; $results = mysql_query($stmt1); $line=1; while (($row = mysql_fetch_assoc($results))) { $readings[$line++]=$row; } } ?> Ken Quote Link to comment Share on other sites More sharing options...
dpwhite Posted September 14, 2008 Author Share Posted September 14, 2008 That cleaned up somethings but here is dump Array ( [1] => Array ( [ukey] => 143 [cid] => [vid] => 4pas1 => 4 [tnum] => 1234 [driver] => dpw [direction] => N [speed] => 45 [date] => 2008-09-07 [time] => 05:01:00 [timestamp] => 20080907050100 [street] => 460 Race St [description] => Garage [city] => Holyoke [state] => MA [lat] => 42.196175 [lon] => -72.612205 ) it is naming the variables when I just want to put relational data in array (i.e 143,,4pas1,1234,dpw,N,45,2008-09-17,05:01:00, 20080907051000, 460 rase st, garage, holyoke, ma, 42.196175,-72612205 Your advice is appreciated dave Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 14, 2008 Share Posted September 14, 2008 Try this: <?php function getdata1() { $stmt1= "select * from latlonreadings"; $results = mysql_query($stmt1); $line=1; while (($row = mysql_fetch_assoc($results))) { $readings[$line++]=implode(',',$row); } } ?> Ken Quote Link to comment Share on other sites More sharing options...
dpwhite Posted September 14, 2008 Author Share Posted September 14, 2008 it seemed to work until I looked at the data in the $row to make it simple: $array = array(1,,3,4pas1,5); does not work it does not like an empty field nor does it like the alpha numeric field 4pas1 so I put data in the empty field and quotes around the alphanumeric $array = array(1,a,3,"4pas1",5); does work any suggestions thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.