2013-10-27 52 views
0

所以我遇到了一個問題,互聯網搜索無能爲力。我試圖找到一種方式來回應「沒有找到結果」,當有人點擊提交,並且它是空的。我過去做過類似的事情,但不記得我是如何做到的。 這裏是我迄今爲止,它不工作:沒有結果發現提交和空()

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

任何想法?

+0

更好地提供信息,你是如何傳遞的值(訪問這樣的:由簡單的表單按鈕打開URL(直接在瀏覽器地址欄寫它或之後從以前的頁面的鏈接),或通過點擊加載從HTML)到這個文件。 – MaNKuR

+0

$ row_Recordset1來自表單POST – Salim

回答

0

在我看來,你忘了寫很多代碼... 首先,我建議你在開始時檢查$ _POST ['Submit'],以便了解頁面

<?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 
} 
?>