search

Home  >  Q&A  >  body text

How to use thinkphp3.2 and ajax fuzzy query

模糊查询

public function search()
{
   $keyword = trim($_POST['$keyword']);
   $Model = M('admin');
   $res=$map['username'] = array('like','%'.$keyword .'%');
   if($res){
        ?????????
   }else{
        ????????
   }
}

zzzzzz2204 days ago819

reply all(1)I'll reply

  • 加特米

    加特米2020-09-08 10:20:09

    public function search(){   $keyword = trim(I('keyword '));   $map['username'] = array('like','%'.$keyword .'%');

    $res=M('admin') ->where($map)->select();

     if($res){        $data['code']=1;

            $data['data']=$res;

       }else{                $data['code']=0;       

                     $data['msg']='没有数据';

       }

    $this->ajaxreturn($data);

    }

    reply
    0
  • Cancelreply