首頁  >  文章  >  後端開發  >  thinkphp实现模模糊糊匹配(学习贵哥代码)

thinkphp实现模模糊糊匹配(学习贵哥代码)

WBOY
WBOY原創
2016-06-13 12:36:09883瀏覽

thinkphp实现模糊匹配(学习贵哥代码)

模板文件:



   


       
        资讯管理-{$site.SITE_INFO.name}
   
            $addCss="";
            $addJs="";
            $currentNav ='资讯管理 > 资讯列表';
       

       
       
   
   
    <script> <br> function import_check(){ <br> var f_content = form1.file.value; <br> var fileext=f_content.substring(f_content.lastIndexOf("."),f_content.length) <br> fileext=fileext.toLowerCase() <br> if (fileext!='.xlsx') <br> { <br> alert("对不起,导入数据&#26684;式必须是xlsx&#26684;式文件哦,请您调整&#26684;式后重新上传,谢谢 !"); <br> return false; <br> } <br> <span style="white-space:pre">else{ document.getElementById("form1").submit();}<br> <span style="white-space:pre"><br> } <br> </script> 
       

           
           

               
               
           

       

       

       
       
       
   


控制器:

    public function index() {
   //作为搜索条件查找某律师的信息
   $where = '1=1';
if(!empty($_GET['name'])) $where .= ' and true_name regexp \'' . trim($_GET['name']) . '\'';
if(!empty($_GET['mobile'])) $where .= ' and law_mobile regexp \'' . trim($_GET['mobile']) . '\'';
if(!empty($_GET['email'])) $where .= ' and email regexp \'' . trim($_GET['email']) . '\'';
if(!empty($_GET['sex'])) $where .= ' and sex regexp \'' . trim($_GET['sex']) . '\'';
if(!empty($_GET['st'])) $where .= ' and first_date >= \'' . substr(str_replace('+', ' ', $_GET['st']),0,4) . '\'';
if(!empty($_GET['et'])) $where .= ' and first_date         $M = M("Constant");  
        $count = $M->where($where)->count();
        import("ORG.Util.Page"); // 导入分页类
   $d = new Page($count,15);  //分页
   $list=$M->limit($d->firstRow.','.$d->listRows)->select();
   $dd=$d->show();
        $this->assign('list', D('Lawerinfo')->listMember($d->firstRow, $d->listRows, $where));
      $this->assign('page',$dd); 
        $this->display();
   }


模型层:

public function listMember($firstRow = 0, $listRows = 20, $where) {
        $M = M('Constant');

$list = $M->where($where)->limit("$firstRow , $listRows")->select();

return $list;
    }


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn