PHP mySQLi_fetch_all:遍历每一行 [英] PHP mySQLi_fetch_all: iterate through each row
本文介绍了PHP mySQLi_fetch_all:遍历每一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在这样检索查询的行:
I am retrieving the rows of my query as such:
$rows = mysqli_fetch_all($result, MYSQLI_ASSOC);
我该怎么办:
(PSEUDO CODE)
for each row in rows
echo row
我只能回显$ rows",但这不允许我在单独的段落中逐行浏览.
I can just "echo $rows" but that doesn't allow me to go through each row on a separate paragraph.
作为第二个问题,我如何遍历一行的每一列:
As a second question, how can I go through each column of a row:
(PSEUDO CODE)
for each row in rows
for each column in row
echo column
推荐答案
我会使用类似这样的东西:
I would use something like this:
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
echo $row['name_of_your_column'];
}
结果是:
$result = mysqli_query($connection, $query);
这篇关于PHP mySQLi_fetch_all:遍历每一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文