定义

mysqli_fetch_row()函数从结果集中提取一行,并将其作为枚举数组返回。

 

语法

PHP mysqli_fetch_row()函数具有以下语法。

mysqli_fetch_row(result);

 

参数

参数 是否必须 描述
result 需要。 由mysqli_query(),mysqli_store_result()或mysqli_use_result()返回的结果集

 

返回值

它返回一个对应于获取的行的字符串数组。如果结果集中没有更多行,则为NULL。

 

实例

从结果集中获取一行,并将其作为枚举数组返回。

<?php
//  http://www.manongjc.com/article/1664.html
//  作者:码农教程
$con=mysqli_connect(\"localhost\",\"my_user\",\"my_password\",\"my_db\");

if (mysqli_connect_errno($con)){
  echo \"Failed to connect to MySQL: \" . mysqli_connect_error();
}

$sql=\"SELECT name FROM emp\";

if ($result=mysqli_query($con,$sql)){
   while ($row=mysqli_fetch_row($result)){
      printf (\"%s (%s)\\n\",$row[0],$row[1]);
   }
   mysqli_free_result($result);
}

mysqli_close($con);
?>
收藏 打印