【问题标题】:How to display the number of search results (custom search script)如何显示搜索结果的数量(自定义搜索脚本)
【发布时间】:2012-02-06 17:23:42
【问题描述】:

我尝试为我的网站制作搜索功能,这是代码http://pastebin.com/GN1NUE7E 但我需要帮助来显示搜索结果的数量。

【问题讨论】:

  • Cameron Diaz 用 PHP 破解?不错!

标签: php search


【解决方案1】:

只保存函数mysql_num_rows的结果:

$rows_num = mysql_num_rows($raw_results);

然后打印出来:

echo $rows_num;

【讨论】:

    【解决方案2】:

    您已经在调用mysql_num_rows(),它会告诉您结果中有多少行。考虑文档中示例中的以下用法:

    <?php
    
      $link = mysql_connect("localhost", "mysql_user", "mysql_password");
      mysql_select_db("database", $link);
    
      $result = mysql_query("SELECT * FROM table1", $link);
      $num_rows = mysql_num_rows($result);
    
      echo "$num_rows Rows\n";
    
    ?>
    

    您的代码中有以下内容:

    if( mysql_num_rows( $raw_results ) > 0 )
    

    您正在检查返回了多少结果。您需要做的就是将mysql_num_rows() 的值分配给一个变量,或者直接调用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-22
      • 2020-05-16
      • 1970-01-01
      • 2021-01-25
      相关资源
      最近更新 更多