How to use the search function in thinkPHP3.2.3
meimei
meimei 2018-04-23 22:47:57
0
3
1201

thinkHow to use the search function in PHP3.2.3? What is wrong with the following

public function index(){
$article=D('article');
$keyboard=isset($_GET['keyboard'])?$_GET ['keyboard']:'';
$where=[]; //Search conditions
if($keyboard){ //Determine whether it is empty
$where['keyboard']=[' like',"%$keyboard%"];
}
$count= $article->where($where)->count();// Query the total number of records that meet the requirements
$Page = new \Think\Page($count,5);// Instantiate the paging class and pass in the total number of records and the number of records displayed on each page (25)
$show = $Page->show() ;//Page display output
$list = $article->where($where)->order('time desc')->limit($Page->firstRow.','.$Page ->listRows)->select();
$this->assign('list',$list);// Assignment data set
$this->assign('page',$ show);// Assignment paging output
$this->display();


meimei
meimei

reply all(2)
猪哥

Print the SQL statement and then execute the SQL statement in the database to test and you will know the result

Alan_繁华

First make sure whether there is a keyboard field in your data. I think there should be no one.

  • reply Yes, the name of the input in the form = "keyboard", isn't it like this?
    meimei author 2018-04-23 23:23:16
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template