php multi-level classification filtering function

不言
Release: 2023-03-29 15:18:02
Original
4896 people have browsed it

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

php multi-level classification filtering function

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.

First go to the back-end code:
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();
    }

}
Copy after login
Front-end code:

    
    
    
    Document
    
    
    
    

不限 红色 黄色 蓝色 绿色

不限 大号 中号 小号

{$vo.title}

{$page}

Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!