PHP站内搜索、多关键字、加亮显示
php搜索代码:
搜索以PHP100开头:
SELECT * FROM teble WHERE title LIKE 'PHP100%'
搜索以PHP100结束:
SELECT * FROM teble WHERE title LIKE '%PHP100'
搜索包含PHP100:
SELECT * FROM teble WHERE title LIKE '%PHP100%'
php搜索代码高亮:
$str = "正品御途T5 行车记录仪 高清夜视 170度广角 重力感应 全场包邮";
$str= preg_replace("/(".$_REQUEST['keywords'].")/i","<font class='ff6'><b>\\1</b></font>",$str);
多个关键词搜索:
$k = explode(' ',$_GET['keywords']);
$count = $k;
for($i=0;$i<$cout;$i++){
$where[] = " like '%".$k[$i]."%'";
}
$where = implode(" and",$where);