所以基本上我试图让搜索获取标题,然后忽略搜索中的标题,但是如果有意义的话,请使用与该标题相关联的关键字并显示具有相同关键字的其他项目。
这是我的代码,但它只搜索你输入的内容。我不知道如何让它做我想做的事。
<?php
$k = $_GET['lookfor'];
$terms = explode(" ",$k);
$query = "SELECT * FROM search WHERE ";
foreach ($terms as $each) {
$i++;
if ($i == 1)
$query .= "keywords LIKE '%$each%' ";
else
$query .= "OR keywords LIKE '%$each%' ";
}
// connect
mysql_connect("localhost", "root", "password");
mysql_select_db("icarus");
$query = mysql_query($query);
$numrows = mysql_num_rows($query);
if ($numrows > 0) {
while ($row = mysql_fetch_assoc($query)){
$id = $row['id'];
$title = $row['title'];
$description = $row['description'];
$keywords = $row['keywords'];
$link = $row['link'];
echo "<li type='1'><h3><a href='$link'>$title</a></h3>
<p>$description</p><br /><br /></li>";
}
}
else
echo "<p>No results found for '<b>$k</b>'. Icarus is still in the early development stage, this can happen.</p>";
// disconnect
mysql_close();
?> </div>
示例数据:
ID: INT
Title : Linkin Park - Hands Held High
Description: About the song
Keywords: rap rock anti war political
Link: youtube link to song
答案 0 :(得分:0)
我想我已经将你要求的东西变成了decypher。
仔细阅读,通过词干搜索术语可以获得输入内容的关键字。