Home > Article > Backend Development > php multi-level classification filtering function
This article mainly introduces the multi-level classification filtering function of PHP, which has certain reference value. Now I share it with everyone. Friends in need can refer to it
Emphasis: I originally wanted to write an ajax filter, but there were some problems with the paging after allocating data, so I wrote a regular one. In fact, this function is not very complicated, it is just a process of checking data, but it still requires some knowledge of the front-end.
assign('res1',$type[0]);// 赋值数据集 $this->assign('res2',$type[1]);// 赋值数据集 if($type[0] =='不限'){ $type[0]=""; } if($type[1] =='不限'){ $type[1]=""; } $data['color']=array('like', "%$type[0]%"); $data['size']=array('like', "%$type[1]%"); } //分页 $count = $goods->where($data)->count();// 查询满足要求的总记录数 $Page = new \Think\Page($count,2);// 实例化分页类 传入总记录数和每页显示的记录数(25) $Page->setConfig('prev','上一页'); $Page->setConfig('next','下一页'); $show = $Page->show();// 分页显示输出 $list = $goods->order('id asc')->where($data)->limit($Page->firstRow.','.$Page->listRows)->select(); $this->assign('list',$list);// 赋值数据集 $this->assign('page',$show);// 赋值分页输出 $this->display(); } }
Document
不限 红色 黄色 蓝色 绿色
不限 大号 中号 小号
{$vo.title}
{$page}
Note: The front section is transmitted through a hidden form, and special attention should be paid to submitting it through get.
Related recommendations:
php multi-level classification query
php multi-level tree menu code
The above is the detailed content of php multi-level classification filtering function. For more information, please follow other related articles on the PHP Chinese website!