php操作mysql输出一个表全部数据,怎么只输出一行

这是我数据库一个叫user的表的内容:

然后在php中写:
$data = "SELECT * FROM user";
$result = mysql_query($data, $con); //SQL查询语句
$row = mysql_fetch_array($result);
print_r($row);
为什么输出是:
Array ( [0] => Wilson [a] => Wilson [1] => Ch [b] => Ch )
为什么第二行和第三行没有输出。。
最新回答
听风入韵

2024-11-07 08:30:16

mysql_fetch_array只是从结果集中取出一行数据,如果你需要输出所有行的内容的话,需要循环取数据。
大致如下(没有测试过,应该没问题):
while ($row = mysql_fetch_array($result)) {
print_r($row);
}
追问
php怎么加超链接,echo写这a标签不行呀。
追答
echo 'XXXX';

因为php是服务器端语言,只要输出html就可以被客户端的浏览器解析,所以输出链接的html就可以了。
软耳兔兔

2024-11-07 05:32:59

select * from member where fenlei in (1,2,3,4) order by id desc Limit 0,10
select * from member where fenlei in (1,2,3,4) order by id desc Limit 10,10
select * from member where fenlei in (1,2,3,4) order by id desc Limit 20,10
select * from member where fenlei in (1,2,3,4) order by id desc Limit 30,10
这样写试试!