[英]Difficulty echoing error message if mysql query returns nothing PEAR PHP
I am struggling to echo an error message stating 'No results' when my mysql query returns nothing. 当我的mysql查询没有返回任何内容时,我正在努力回应一条错误消息,声明“没有结果”。 I am using PEAR.
我正在使用PEAR。 Here is what I have at the moment.
这就是我现在所拥有的。
while($rows =& $output->fetchRow()) {
if (numRows($query)== 0){
echo 'No results';
}
else {
echo 'data found';
}
}
Any help will be greatly appreciated, thanks for checking out my question. 非常感谢任何帮助,谢谢你查看我的问题。
If there are no results, fetchRow
won't return anything, which means the loop doesn't get executed at all, which means the code inside the loop won't either. 如果没有结果,
fetchRow
将不返回任何内容,这意味着循环根本不会执行,这意味着循环内的代码也不会。 The logic is: 逻辑是:
if numRows == 0
echo error
else
while fetchRow
echo result
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.