前台页面,将order写入,开始时为空

<a href="{:U('find','type=2&keyword='.$keyword.'&catid='.$catid.'&brand_id='.$brand_id.'&user_per='.$user_per.'&order='.$order)}"> 
    <li class="fu_2">
        <span class="fu_22">销量</span>
        <img src="{:CUSTOM_TEMPLATE_PATH}Index/index/img/faxian_2.png" width="16">
    </li>
</a>


点按钮给后端php

1第一次点按钮为空,默认给它降序。并给前端升序变量,为第二次点击做准备

2第二次点按钮点升序,提交给PHP。当判断为升序时,将降序变量给前端,为第三次点击做准备


if(!isset($_GET['order'])){
				$order = array('sales_volume'=>'desc');
				$this->assign('order',"asc");
			}elseif(($_GET['order'])=="asc"){
				$order = array('sales_volume'=>'asc');
				$this->assign('order',"desc");
			}else{
				$order = array('sales_volume'=>'desc');
				$this->assign('order',"asc");
			}



本文转载:CSDN博客