提交时未找到结果,并且为 empty()


No results found upon submitting and empty()

所以我遇到了一个互联网搜索无济于事的问题。我正在尝试找到一种方法来回显"未找到结果",当有人单击提交并且它显示为空时。我过去做过类似的事情,但不记得我是怎么做到的。这是我到目前为止所拥有的,它不起作用:

<?php
if ( empty($row_Recordset1) && isset($_POST['Submit']) ){
    echo "No results found";
}

有什么想法吗?

在我看来,

你忘记写了很多代码......首先,我建议您在开头检查 $_POST['提交'],以便通过简单地打开 URL(直接将其写入浏览器地址栏中或点击上一页的链接)或单击表单按钮来了解页面是否已加载:

<?php
if (isset($_POST['Submit'])){
   // someone submitted the form
   // so, here you must check if results are available according to the submitted data
   //here all the necessary code to open a database connection, perform a mysql query  and save the results in $row_Recordset1
   //then you can check if the query returned no results
   if (empty($row_Recordset1) {
      echo "No results found"; 
   }
   else {
      // the code to print results here
   }
}
else {
   // no one submitted the form
   // so, here you should put the code to draw your html form
} 
?>