$res=mysqli_query($con,$query);
while($row = mysqli_fetch_row($query))
{
echo $row;
}
这是我的代码,我收到如下错误:
Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in C:\xampp\htdocs\smarty_framework\workloc\action_files\passAction.php on line 17
答案 0 :(得分:0)
您似乎将实际查询传递给mysqli_fetch_row,而不是查询结果。尝试将其更改为:
$res=mysqli_query($con,$query);
while($row = mysqli_fetch_row($res))
{
echo $row;
}
答案 1 :(得分:0)
您正在将sql查询传递给mysqli_fetch_row();
$res=mysqli_query($con,$query);
while($row = mysqli_fetch_row($query))
{
//your code
}
更改为:
$res=mysqli_query($con,$query);
while($row = mysqli_fetch_row($res))
{
// your code
}
See 了解更多信息
另外,根据您的问题标题“如何显示查询结果的数量” - 您可以使用mysqli_num_rows()来获取查询返回的结果数。
像这样:
$res=mysqli_query($con,$query);
$count = mysqli_num_rows($res);
//echo $count; /* This will display the count */
if($count > 0)
{
while($row = mysqli_fetch_row($res))
{
// your code
}
}