Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是查询
$db=mysql_connect('localhost','root','root'); mysql_select_db('test'); $query=mysql_query("SELECT * FROM table"); $r=mysql_fetch_assoc($query); print_r($r);
它只给了我第一个元素。
但是在 PhpMyAdmin 中,它给了我所有的元素。
我怎样才能使它在 PHP 中工作?
mysql_fetch_assoc每个函数调用获取一行。你想要的可能是:
mysql_fetch_assoc
while($r = mysql_fetch_assoc($query)){ print_r($r); }