【发布时间】:2011-04-15 07:39:42
【问题描述】:
例如我有这张表
+------+---------+------+
| id | item_id | type |
+------+---------+------+
| 1 | 2 | book |
| 1 | 1 | pen |
+------+---------+------+
我想在 php 脚本中检索 id=1 的所有数据,这是我使用的代码
<?php
$stat="select item_id, type from tb where id=1";
$query = mysqli_query($con, $stat);
$result = mysqli_fetch_array($query,MYSQLI_ASSOC);
print_r($result);
?>
结果是:Array ( [item_id] => 2 [type] => book )
而且这只是第一行,如何检索php代码中的所有行?
【问题讨论】:
-
查看this question的答案