【问题标题】:No results found未找到结果
【发布时间】:2011-02-14 19:54:18
【问题描述】:

如果使用这样的查询没有显示匹配的结果,我该如何显示“未找到结果”:

  $query="SELECT * FROM actresses where actress_id = '$actressid' and production_full_name LIKE '%$q%'";  
    $result=mysql_query($query);

   $num=mysql_numrows($result);

  mysql_close();

    echo "";

  $i=0;
  while ($i < $num) {

   $1=mysql_result($result,$i,"production_full_name");
    $2=mysql_result($result,$i,"production_id");
    $3=mysql_result($result,$i,"actress");


     echo "<br><div id=linkcontain><a id=slink   href=$data/actress.php?id=$2>$3</a><div id=production>$1</div></div>";

     echo "";

      $i++;
     }

【问题讨论】:

    标签: php mysql search full-text-search


    【解决方案1】:
    if(mysql_num_rows($result) < 1) {
       echo "No rows found";
    }
    

    你是这个意思?

    【讨论】:

      【解决方案2】:
      if(mysql_num_rows($result) > 0)
      {
      while($row = mysql_fetch_array($result))
      {
      $1 = $row['production_full_name];
      $2 = $row['production_id'];
      $3 = $row['actress'];
      }
      }
      else
      {
      echo "No Results Found";
      }
      

      如果您使用函数返回结果集,则必须使用 is_ 方法对结果进行类型转换。

      if(is_array($result))
      {
      // Logic to be implemented.
      }
      else
      {
      echo $result;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-11-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-12-03
        • 2023-03-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多