我试图从表'学生'中提取所有行。 但它只返回数组中的第一行。 如何获取数组中的所有行?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