【发布时间】:2014-05-01 08:54:10
【问题描述】:
我制作了一个 mysql/php 搜索引擎,在其中添加了带有关键字 google 搜索引擎的 google url 和带有关键字 yahoo 搜索引擎的另一个 yahoo url。如果我在搜索框中输入 google search engine,如何让 google url 首先出现?
这是代码:
//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
【问题讨论】:
-
我希望没有人愿意搜索任何带有撇号的东西。
标签: php mysql search-engine