搜索

步骤:
1.接收ajax传过来的搜索条件
  id,name...
2.拼接搜索条件
  $where='1=1'
  判断使用哪一条搜索条件
  if(!empty($id)){
   $where.=" and name like '%$name%'"
}else{
   $where.=" and name like '%$name%'"
}
3.展示搜索结果
  分页
  分页类
  分页类运行结果就是搜索结果
 <1.搜索条件在搜索结果里变红
  <foreach>遍历搜索结果
   $red_name="<font color='red'>$name</font>"
   $red_id="<font color='red'>$id</font>"
   $list[$key]['name']=str_replace($name,$red_name,$val['name']);
   $list[$key]['id']=str_replace($id,$red_id,$val['id']);
  <2.赋值,展示

原文地址:https://www.cnblogs.com/ymk0375/p/6257741.html