搜索功能,准备好的语句不显示结果

时间:2016-08-05 03:16:35

标签: php mysqli

当搜索完全匹配所有显示时。但是当没有匹配时,不显示无结果消息。请对此有任何见解。先谢谢

[host.com] [Fri Aug 05 03:57:33 2016] [error] [client 24.28.29.44] client denied by server configuration: /home/domains/host.com/.htaccess

1 个答案:

答案 0 :(得分:0)

正如Madan Sapkota所说:" if(!$ query){仅检查是否存在任何错误"。

你需要使用一个函数来计算结果,比如mysqli_stmt_num_rows():

if(mysqli_stmt_num_rows ( $stmt ) == 0 ){ echo "there is no result";}
// The while loop after won't be run when no result are found, no need to put an else here.
while (mysqli_stmt_fetch($stmt)) {
  ...    
}