Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 提交时未找到结果且为空()_Php_Submit - Fatal编程技术网

Php 提交时未找到结果且为空()

Php 提交时未找到结果且为空(),php,submit,Php,Submit,所以我遇到了一个网络搜索无法解决的问题。我正试图找到一种方法,当有人点击提交,结果显示为空时,回应“找不到结果”。我过去也做过类似的事情,但不记得是怎么做的。 以下是我目前所掌握的,但它不起作用: <?php if ( empty($row_Recordset1) && isset($_POST['Submit']) ){ echo "No results found"; } 我觉得你好像忘了写很多代码。。。 首先,我建议您在开始时检查$_POST['Submit

所以我遇到了一个网络搜索无法解决的问题。我正试图找到一种方法,当有人点击提交,结果显示为空时,回应“找不到结果”。我过去也做过类似的事情,但不记得是怎么做的。 以下是我目前所掌握的,但它不起作用:

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

我觉得你好像忘了写很多代码。。。
首先,我建议您在开始时检查$_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
} 
?>

最好提供您如何将值(从html访问)传递到此文件的信息。是否$row_Recordset1来自表单POST