solarisuser Posted June 29, 2007 Share Posted June 29, 2007 Hello All, I can't get this to work right, $aResults should be ~200 records (mysql query is correct)... $aResults = array(); $get = mysql_query("SELECT id as id,tool as value,pan as info FROM s.tb1 LIMIT 0,200"); $row = mysql_fetch_array($get); $num = mysql_num_rows($get); for ($i=0;$i<count($num);$i++) { $aResults[$i]['id'] = $row['id']; $aResults[$i]['value'] = $row['value']; $aResults[$i]['info'] = $row['info']; } var_dump($aResults); Thanks! Quote Link to comment Share on other sites More sharing options...
per1os Posted June 29, 2007 Share Posted June 29, 2007 $aResults = array(); $get = mysql_query("SELECT id as id,tool as value,pan as info FROM s.tb1 LIMIT 0,200"); while ($row = mysql_fetch_array($get)) { $aResults[] = $row; } var_dump($aResults); You have to iterate through the query to get all the records. Quote Link to comment Share on other sites More sharing options...
Barand Posted June 29, 2007 Share Posted June 29, 2007 Better to use mysql_fetch_assoc() as everything will be stored twice with mysql_fetch_array (associative index and numeric index) Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 29, 2007 Share Posted June 29, 2007 $aResults = array(); $get = mysql_query("SELECT id as id,tool as value,pan as info FROM s.tb1 LIMIT 0,200"); $num = mysql_num_rows($get); for ($i=0;$i<count($num);$i++) { $row = mysql_fetch_array($get); $aResults[$i]['id'] = $row['id']; $aResults[$i]['value'] = $row['value']; $aResults[$i]['info'] = $row['info']; } var_dump($aResults); thats the code you have the prob is that you put the $row = mysql_fetch_array($get); outside the loop any way it will work now but its better to use the while loop its shorter 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.