If I wanted to fetch multiple ROWS without doing the while loop like this:
while ($data = mysql_fetch_array($select)) {}
how can I do that in mysql and php?
mysql_fetch_array()
is intended to fetch a single row from a resultset, so there is no reasonable way not using a while. Use mysqli with fetch_all or get used to while :)
Your comment:
$_SESSION["whatever"]=array();
while($data = mysql_fetch_array($select)) {
array_push($_SESSION["whatever"], $data);
}
With mysqli you have a fetch_all
function. From the manual:
mysqli_result::fetch_all -- mysqli_fetch_all — Fetches all result rows as an associative array, a numeric array, or both