我做了一個mysql/php搜索引擎,其中我添加了帶有關鍵字google搜索引擎的谷歌網址和另外一個帶有關鍵字yahoo搜索引擎的雅虎網址。如果我在搜索框上輸入谷歌搜索引擎,我該如何讓谷歌網址首先出現?如何使精確關鍵字搜索首先出現?
這是代碼:
//connect to database
mysql_connect("","","");
mysql_select_db("");
//explode out search term
$search_exploded = explode(" ",$search);
foreach($search_exploded as $search_each)
{
//construct query
$x++;
if ($x==1)
$construct .= "Keywords LIKE '%$search_each%'";
else
$construct .= " OR Keywords LIKE '%$search_each%'";
}
//echo outconstruct
$constructx = "SELECT * FROM searchengine WHERE $construct";
$construct = "SELECT * FROM searchengine WHERE $construct LIMIT $s,$e";
$run = mysql_query($constructx);
$foundnum = mysql_num_rows($run);
$run_two = mysql_query("$construct");
if ($foundnum==0)
echo "No results found for <b>$search</b>";
else
我希望沒有人想要搜索任何帶有撇號的東西。 – icktoofay 2011-05-28 21:13:35
小鮑比桌子? :D – Halcyon 2011-05-28 21:14:16