thinkphp3使用like查询
文章描述:
thinkphp3使用like模糊查询内容
html
搜索框
<form action="" method="post">
     <input type="text" name="key"/>
     <input type="submit" />
</form>php
查询条件
if(!empty(I('key'))){
   $condtion['nickname']=array("like","%".trim(I('key'))."%");
}查询语句
$userModel = M('user');
$list = $userModel->where($condtion)->select();分配变量
$this->assign('list',$list);
$this->display();html
模板循环
<table>
 <foreach name="list" item="vo" key="k" >
  <tr>
   <td>{$k}</td><td>{$vo.nickname}</td>
  </tr>
 </foreach>
</table>
发布时间:2021/06/28 
                
            
发表评论