您好 php 的另一个问题我不确定为什么它不起作用,但这里是代码:
<?php include 'db.inc.php';function search_results($keywords){$returned_results = array();
$where = "";
$keywords = preg_split('/[\s]+/', $keywords);
$total_keywords = count($keywords);
foreach($keywords as $key=>$keyword){
$where .="`keywords` LIKE '%$keyword%'";
if ($key != ($total_keywords - 1 )){
$where .= " AND ";
}
}
$results = "SELECT `document_name` ,LEFT(`first_paragraph`,70) as `first_paragraph` FROM `documents` WHERE $where ";
$results_num = ($results = mysql_query($results)) ? mysql_num_rows($results) : 0 ;
if ($results_num == 0){
return false;
}else {
while($results_row = mysql_fetch_assoc($results)){
$returned_results[] = array(
'title' => $results_row['document_name'],
'description' => $results_row['first_paragraph']
);
}
return $returned_results;
}
}
?>
我目前正在尝试使用 PDO 来实现它,但我不确定如何.. 我不确定这是否是问题,但我没有从 mysql Thx 得到任何东西!