Alex Rivera | Logout

Get all mysql selected rows into an array

Asked 2012-06-29T15:14:39.853
25

I am wondering if there a function in php that can allow me put all my selected data in an array .Currently i am using mysql_fetch_array and as i have read in the manual,that function won't fetch every record in the table.

$result = mysql_query("SELECT * FROM $tableName");            
$array = mysql_fetch_array($result);

  echo json_encode($array);
Edit
Report

1 Answer

11
  1. Loop through the results and place each one in an array

  2. use mysqli_fetch_all() to get them all at one time

answered 2012-06-29T15:18:25.790

Your Answer