0

这是我的搜索查询,如果没有结果匹配,我该如何显示错误,请帮助

 $sql="SELECT  * FROM course WHERE course_name LIKE '%" . $search_name .  "%'";
              //-run  the query against the mysql query function
              $result=mysql_query($sql);
4

2 回答 2

4
$sql="SELECT  * FROM course WHERE course_name LIKE '%" . $search_name .  "%'";
              //-run  the query against the mysql query function
$result=mysql_query($sql);

if(mysql_num_rows($result) < 1)
{
    echo 'There were no results.';
}
于 2012-11-26T09:29:15.300 回答
0
if(mysql_num_rows($sql)=="0")
{
echo "----------------"; //your code here
}
于 2012-11-26T09:30:31.507 回答