我有这段代码,它希望将我输入的单词转换成一个数组,然后应该在数据库中搜索数组。该数据库具有由爬虫在网站中扫描的单词的行。
数组代码似乎不起作用:(我的查询如下:
if( isset($_POST['keyword']) ){
$k = $_POST['keyword'];
}else{
$k = '';
}
$k = ( isset($_POST['keyword']) )? trim($_POST['keyword']) : '';
$terms = (strlen($k) > 0)? explode(' ', $k) : Array();
$keyword = addslashes( $k);
$results = addslashes( $_POST['results'] );
/* Execute the query that performs the actual search in the DB: */
$result = mysql_query(" SELECT p.page_url AS url,
COUNT(*) AS occurrences
FROM page p, word w, occurrence o
WHERE p.page_id = o.page_id AND
w.word_id = o.word_id AND
w.word_word = \"$keyword\"
GROUP BY p.page_id
ORDER BY occurrences DESC
LIMIT $results" );