开发者

No results found

How can i do show "no results found" if no matching results show up using a query like this:

  $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++;开发者_JS百科
     }


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

You mean that?


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

If you are using a function to return the result set then you have to typecast the result using the is_ methods.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜