我試圖從表'學生'中提取所有行。 但它只返回數組中的第一行。 如何獲取數組中的所有行?Mysql使用php選擇查詢
我的代碼是 -
<?php
// con ref
$dbCon = mysql_connect("localhost","root","") or die("connection problem".mysql_error());
// db con
mysql_select_db("mysql_db",$dbCon);
$sql = "select * from student ";
$data = mysql_query($sql);
$row = mysql_fetch_array($data);
print_r($row);
?>
谷歌的功能是你的朋友。 「獲取數組中的所有行」=許多結果:https://www.google.com/webhp?sourceid=chrome-instant&ion=1&ie=UTF-8#hl=zh-CN&safe=active&sclient=psy-ab&q=fetch%20all %20th%20rows%20in%20an%20array&oq =&gs_l =&pbx = 1&fp = d76eed8efe782f95&ion = 1&bav = on.2,or.r_cp.r_qf。&bvm = bv.44158598,d.aWM&biw = 1680&bih = 903 – Robert 2013-03-24 17:41:30
[Please,don'在新代碼中使用mysql_ *函數](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php)。他們不再被維護,並[正式棄用](https://wiki.php.net/rfc/mysql_deprecation)。看到紅色框?請改爲了解準備好的語句,並使用[pdo](https://wiki.php.net/rfc/mysql_deprecation)或[mysqli](http://stackoverflow.com/questions/tagged/mysqli)。 – zessx 2013-03-24 17:41:53