0

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

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

有任何想法吗?

4

1 回答 1

0

在我看来你忘记写很多代码了......首先,我建议你在开始时检查 $_POST['Submit'] ,以便通过简单地打开来了解页面是否已加载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
} 
?>
于 2013-10-27T11:58:31.777 回答