概述
我必须承认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()?所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复