MySQLi仅显示一个结果 [英] MySQLi only showing one result

查看:60
本文介绍了MySQLi仅显示一个结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的问题,我的MySQLi函数在var_dump中只显示一行/结果:

I have a simple problem, that my MySQLi function only shows one row / result in var_dump:

$sql       = $db->query('SELECT * FROM '.$db_prefix.'_posts');
$row       = $sql->fetch_array();

var_dump($row);

就是这样. phpMyAdmin中的查询显示3个结果.仅此一个1.它也不适用于fetch_assoc()或fetch_array().

That's it. The query in phpMyAdmin shows 3 results. This one only 1. It also doesn't work with fetch_assoc() or fetch_array().

另外,我想列出与"fetch_array()"相同的表的键.

Also, I want to have the keys of the table being listed as with "fetch_array()".

推荐答案

尝试一会儿循环:

while($row = $sql->fetch_row())
{
   var_dump($row);
}

因为fetch_row()fetch_array()fetch_assoc()在每次被调用时都会返回一行,直到它超出行数"为止.

Because fetch_row(), fetch_array(), fetch_assoc() will all return one row every singe time it's being called untill it is 'out of rows'.

这篇关于MySQLi仅显示一个结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆