How do I store all results from an SQL query in a multidimensional array?
$data = array(); // create a variable to hold the informationwhile (($row = mysql_fetch_array($result, MYSQL_ASSOC)) !== false){ $data[] = $row; // add the row in to the results (data) array}print_r($data); // print result
Update Feb '17 Now that it's 2017, it's advised you use PDOs over mysql_*. A lot safer and can return this natively with fetchAll
(as shown in `TrexXx's answer).