时间:2021-07-01 10:21:17 帮助过:14人阅读
二:mysqli_fetch_assos();
查询结果:array([name]=>小王)
查询:
while ($row = mysqli_fetch_assoc($result)) {
$memberlist = $row['memberlist'];
}//end while()
三、mysqli_fetch_array();
查询结果:array([0]=>小王 [name]=>小王)
查询:
while ($row = mysqli_fetch_assoc($result)) {
$memberlist = $row['memberlist'];
$memberlist = $row[0];
}//end while()
四、fetch_array();
查询结果:array([0]=>小王 [name]=>小王)
查询:` sql=“select?fromuser”; result = conn?>query( sql);
if (result)
{
if (result->num_rows>0)
{
while ( rows= result->fetch_array()) {
print_r( rows);echo“rows[‘id′]:”. rows[‘id’];
echo “
rows[‘name’]:”. rows[‘name′];echo“rows[‘pwd′]:”. rows[‘pwd’];
}//end while()
}else{
echo “
查询结果为空!”;
}//end if()
}else{
echo “
查询失败!”;
}//end if() `
从上面可以看出不同的函数输出的格式也是不一样的,mysqli_fetch_row()返回的是以数字做索引的,mysqli_fetch_assos()是以关键字做索引的,而mysqli_fetch_array()和fetch_array()即使用数字也使用关键字做索引。