Is it possible to change while
by foreach
in mysql_fetch_row
in PHP?
For example
$result = mysql_query("SELECT * FROM test");
while ($row = mysql_fetch_row($result)) {
print_r($row);
}
This will take all records(rows) from query SELECT * FROM test
.
But, if foreach is used
foreach (mysql_fetch_row($result) as $row) {
print_r($row);
}
This will take only first record(row) from query SELECT * FROM test
.
Is it possible get all records by foreach
loop when using with mysql_fetch_row
?