2012-11-26 111 views
0

這是我的搜索查詢,如果沒有結果的比賽,我怎麼能顯示錯誤,請 幫助搜索結果錯誤

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

回答

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.'; 
} 
+0

感謝它爲我工作 –

0
if(mysql_num_rows($sql)=="0") 
{ 
echo "----------------"; //your code here 
}