未找到结果

时间:2011-02-14 19:54:18

标签: php mysql search full-text-search

如果没有使用如下查询显示匹配结果,我怎么能显示“找不到结果”:

  $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++;
     }

2 个答案:

答案 0 :(得分:3)

if(mysql_num_rows($result) < 1) {
   echo "No rows found";
}

你的意思是?

答案 1 :(得分:0)

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