我认为正确的搜索引擎的 HTML 代码
我的搜索引擎
PHP 代码从这里开始,我相信错误来自这里
if(!$button)
echo "you didn't submit a keyword"; else
{
if(strlen($search)<=1)
echo "Search term too short";
else{
echo "You searched for <b>$search</b> <hr size='1'></br>";
mysql_connect("localhost","root","");
mysql_select_db("testproject");
$search_exploded = explode (" ", $search);
foreach($search_exploded as $search_each)
{
$x = NULL; $construct = NULL;
$x++;
if($x==1)
$construct .="keywords LIKE '%$search_each%'";
else
$construct .="AND keywords LIKE '%$search_each%'";
}
$construct ="SELECT * FROM members WHERE $construct";
$run = mysql_query($construct);
$foundnum = mysql_num_rows($run);
if ($foundnum==0)
echo "Sorry, there are no matching result for <b>$search</b>.
</br></br>1. Try more general words.";
else
{
echo "$foundnum results found !<p>";
while($runrows = mysql_fetch_assoc($run))
{
$username = $runrows ['username'];
$email = $runrows ['email'];
}
}
}
}
?>
不断得到:警告:mysql_num_rows() 期望参数 1 是资源,布尔值