cinek Posted October 30, 2010 Share Posted October 30, 2010 I'm trying to return everything from a table using mysql_fetch_array, but it only returns the last row. here's the code while($row = mysql_fetch_array($result)) { $data['rows'] = array( "id" => $row['id'], "Company" => $row['Company'], "Name" => $row['Name'], "Status" => $row['Status']); } how can I fix this? Link to comment Share on other sites More sharing options...
Synook Posted October 30, 2010 Share Posted October 30, 2010 You're overwriting data['rows'] every time. Maybe you wanted to do this instead: $data['rows'] = array();while($row = mysql_fetch_array($result)) { $data['rows'][] = array( "id" => $row['id'], "Company" => $row['Company'], "Name" => $row['Name'], "Status" => $row['Status']); } P.S. mysql_fetch_array() does only return one row at a time - that's why there's the while loop. Link to comment Share on other sites More sharing options...
cinek Posted October 30, 2010 Author Share Posted October 30, 2010 thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.