dongou3158 2015-01-10 13:11
浏览 34


I have a search box and the user should type a transaction number to match a specific record. I was wondering how you would code it if nothing was typed and if it doesn't match a record/doesn't exist. I want it to display No Results, something like that.

search page:

<form action="admin_srchRslt.php" method="get">
    <br/>Search Transaction No.<br/>
    <input name="search" type="text" id="search" />
    <input name="btnSearch" type="submit" id="btnSearch" value="Search" />
  • 写回答

1条回答 默认 最新

  • dpfwhb7470 2015-01-10 13:17

    In admin_srchRslt.php, when you determine that no results were found, use header() to redirect to your "no results" page:

    header("Location: /no_results.html");

    A better approach may be to send users to the same page every time but to simply change the results section of the page. If you are using an MVC framework, simply update the 'results' block in your view with the message that no results were found. Otherwise, you could do something like:

    if (empty($results)) // If the $results array contains no data
        echo "No results were found";
        foreach ($results as $result)
             // Display the result
    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 谁会做这个啊#ensp#Boson NetSim
  • ¥15 如何编写针对TPS6503320FRGE型号的电源管理芯片的编程代码?
  • ¥15 设计简单目录管理系统,要满足以下内容
  • ¥15 关于九十度混合耦合器信号分析问题
  • ¥15 Cesm如何关闭不用的模块呢
  • ¥15 vue2两层数据导出为excle
  • ¥15 有人能帮我做一下这个项目吗
  • ¥15 网络上传速率比下载速率高
  • ¥15 (标签-游戏|关键词-网页游戏)
  • ¥15 这个咋搞🥹可能需要手把手教