所以我遇到了互联网搜索无法解决的问题。我试图找到一种方式来回应"没有找到结果"当有人点击提交时它出现空白。我过去做过类似的事情,但不记得我是怎么做到的。 以下是我到目前为止所做的工作,并不起作用:
<?php
if ( empty($row_Recordset1) && isset($_POST['Submit']) ){
echo "No results found";
}
有什么想法吗?
答案 0 :(得分: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
}
?>