我是靠谱客的博主 完美菠萝,这篇文章主要介绍mysql中mysqli_query_如何在PHP中使用mysqli_query()?,现在分享给大家,希望可以做个参考。

我必须承认mysqli_query()手动条目不包含有关如何获取多行的简洁示例.可能是因为常规是常规的,几十年来PHP人都知道:

$result = mysqli_query($link,"DESCRIBE students");

while ($row = $result->fetch_assoc())

{

foreach($row as $value) echo "

$value";

}

如果要打印列标题,则必须先将数据选择为嵌套数组,然后使用第一行的键:

// getting all the rows from the query

// note that handy feature of OOP syntax

$data = $link->query("DESC students")->fetch_all(MYSQLI_ASSOC);

// getting keys from the first row

$header = array_keys(reset($data));

// printing them

foreach ($header as $value) echo "

$value";

// finally printing the data

foreach ($data as $row)

{

foreach($row as $value) echo "

$value";

}

某些主机可能不支持fetch_all()函数.在这种情况下,通常填充$data数组:

$data = array();

$result

最后

以上就是完美菠萝最近收集整理的关于mysql中mysqli_query_如何在PHP中使用mysqli_query()?的全部内容,更多相关mysql中mysqli_query_如何在PHP中使用mysqli_query()内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部