Home > php教程 > php手册 > body text

php实现多级分类筛选程序代码

WBOY
Release: 2016-06-02 09:13:34
Original
1636 people have browsed it

现在这种多选择功能在很多网站都有,如现在很多电商网站都有N个条件选择了,下面小编为各位介绍一个简单的多级分类筛选实现方法。

主要注意这边有一个 $$这是变量的变量。 以后估计会常用这个做开发。

<?php
$conditions = array(&#39;price&#39;,&#39;color&#39;,&#39;metal&#39;);//要进行筛选的字段放在这里
$price = $color = $metal=&#39;&#39;;//先给需要筛选的字段赋空值,这些值将输出到页面的hidden fileds 中
//以下循环给已经进行的筛选赋值,以便能够在下一次筛选中保留
foreach($conditions as $value){
    if(isset($_GET[$value])){ 
        $$value = $_GET[$value];
    }
}
//以下是演示输出$_GET数据
echo &#39;<pre class="brush:php;toolbar:false">&#39;;
print_r($_GET);
echo &#39;
Copy after login
'; ?> 分类筛选演示
价格:不限 100-1000 1001-2000 2001-3000
颜色:红色 蓝色
材质:纯金 纯银


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 Recommendations
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!