不需要ajax实现搜索数据保留翻页

今天突发奇想,不需要ajax实现翻页效果,并且保留页面搜索数据及其他填写数据,在DZ框架中实现,效果一样!

<body>
<style type="text/css">
html{_overflow-y:scroll}
.one {background-color:#abcdef !important;}
.color-1 { color:#e4393c!important; }
.color-2 { color:#53A0E3!important; }
.color-3 { color:#8C98B6!important; }
.color-4 { color:#5B910B!important; }
.color-5 { color:#bb505d!important; }
.color-6 { color:#8552a1!important; }
</style>




</head>
<body>
<div class="subnav">
        <div class="content-menu ib-a blue line-x">
        <a href='javascript:;' class="on"><em>用户充值列表</em></a>   </div>
</div>
<style type="text/css">
    html{_overflow-y:scroll}
</style><div class="pad-lr-10">
<form action="" method="get" id='formSearch'>
<input type="hidden" value="mingxi" name="m">
<input type="hidden" value="depositlists" name="c">
<table width="100%" cellspacing="0" class="search-form">
    <tbody>
        <tr>
        <td>
        <div class="explain-col">  
                充值操作:
                <select name="ispay">
                    <option  selected = "selected"  value='<?php echo $ispay;?>' class='one'><?php echo $str1;?></option>
                    <option value="0" >全部</option>
                    <option value="1"  >已成功</option>
                    <option value="2"  >已取消</option>
                </select>  
                &nbsp;&nbsp;&nbsp; 
                      充值类型:
                <select name="pay_type">
                    <option  selected = "selected" value='<?php echo $pay_type;?>'  class='one'><?php echo $str2;?></option>
                    <option value="0" >全部</option>
                    <option value="1"  >支付宝</option>
                    <option value="2"  >微信</option>
                </select>   
                &nbsp;&nbsp;&nbsp; 
                <select name="p_type">
                    <option  selected = "selected" value='<?php echo $p_type;?>'  class='one'><?php echo $str3;?></option>
                    <option value='1' >姓名</option>
                    <option value='2' >会员Id</option>
                </select>      

                <input name="keyword" type="text" value="<?php echo $keyword;?>" class="input-text" />         
                                         申请时间:
                 <script type="text/javascript" src="static/js/my97date/WdatePicker.js"></script>
                 <input type="text" name="start_time" id="start_time" value="<?php echo $StartDate;?>" size="10"  class="date" onclick="WdatePicker()" readonly>&nbsp;-
                <input type="text" name="end_time" id="end_time" value="<?php echo $EndDate; ?>" size="10"  class="date" onclick="WdatePicker()" readonly>&nbsp;

                <a href="javascript:void(0);" id="ncsubmit" class="btn-search tooltip" title="查询">&nbsp;</a>
              <h3>总计 :&nbsp;<b class='color-4'><?php echo $number;?></b>&nbsp;条记录<h3/>

    </div>
        </td>
        </tr>
    </tbody>
</table>
</form>

<form name="myform" action="/index.php?m=Member&c=Deposite&a=delete" method="post">
<div class="table-list">
<table width="100%" cellspacing="0">
    <thead>
        <tr>
            <th align="center" width="6%" >充值ID</th>
            <th align="center" width="6%">充值姓名</th>
            <th align="center" width="6%">充值单号</th>
            <th align="center" width="8%">充值金额</th>
            <th align="center" width="6%">充值方式</th>
            <th align="center" width="12%">充值时间</th>
            <th align="center" width="8%">是否到账</th>
        </tr>
    </thead>
<tbody id="test">
<?php foreach($list as $vo){?>
    <tr <?php if($vo['ispay'] != 1){ echo "style='background-color:#ccc;'"; }?>>
        <td align="center"><?php echo $vo['userid'];?></td>
        <td align="center"><?php echo $vo['realname']; ?></td>
        <td align="center"><?php echo $vo['out_trade_no']; ?></td>
        <td align="center" style='color:#FF6600;'><?php echo $vo['amount']; ?></td>
        <td align="center"><?php echo $vo['pay_type_name']; ?></td>
        <td align="center"><?php echo date('Y/m/d H:i',$vo['add_time']);?></td>
        <td align="center"><?php if($vo['ispay']==1){ echo '√';}else{ echo '×';} ?></td>
    </tr>
     <?php }?>   
</tbody>
</table>
<div id="pages"><div><?php echo pageft($number,$pagesize,$page,1,0,0,8,$pageurl,2);?>   </div></div>
</div>
</form>
</div>
<script>

$(function () {

    $('#ncsubmit').click(function(){
        if ($("#start_time").val() != "" && $("#end_time").val() != "") {
            if (new Date($("#start_time").val().replace(/-/g, "/")) > new Date($("#end_time").val().replace(/-/g, "/"))) {
                alert("开始时间不能大于结束时间");
                return false;
            }
        } 
        $('#formSearch').submit();
    });

});
</script>

php代码如下

public function depositlists(){
        $ispay=(int)$_GET['ispay'];//是否充值
        $pay_type=(int)$_GET['pay_type'];//充值类型:支付宝,微信
        $p_type=empty($_GET['p_type'])?1:intval($_GET['p_type']);//搜索类型 1,用户名,2 id
        $keyword=trim($_GET['keyword']);
        $StartDate=trim($_GET['start_time']);
        $Starttime=strtotime($StartDate);
        $EndDate=trim($_GET['end_time']);
        $Endtime=strtotime($EndDate);
        if(empty($ispay)){
            $str1='全部';
        }else{
            if($ispay==1){
                $str1='已成功';
            }else{
                $str1='已取消';
            }
        }
        if(empty($pay_type)){
            $str2='全部';
        }else{
            if($pay_type==1){
                $str2='支付宝';
            }else{
                $str2='微信';
            }
        }
        if($p_type==1){
            $str3='姓名';
        }else{
            $str3='ID';
        }
        if($ispay>0){
            if($ispay==1){
                $where="`a`.`ispay`= 1";
            }else{
                $where="`a`.`ispay`= 0";
            }

        }else{
            $where=" `a`.`id`> 0";
        }
        if($pay_type>0){
            if($pay_type==1){
                $where.=" AND `a`.`paytype` = 4";
            }else{
                $where.=" AND `a`.`paytype` IN (1,2,5)";
            }
        }
        if($p_type==2 && !empty($keyword)){
            $keyword=(int)$keyword;
            $where.=" AND `a`.`userid` = $keyword";
        }
        if($p_type==1 && !empty($keyword)){

            $where.=" AND `b`.`realname` LIKE '%$keyword%'";
        }
        if(!empty($StartDate)){
            $where.=" and `a`.`add_time`>$Starttime";
        }
        if(!empty($EndDate)){
            $where.=" and `a`.`add_time`<$Endtime";
        }
        require SITE_ROOT.'source/function/function_page.php';
        $pagesize = 12;
        $page = ! empty ($_GET ['page']) ? (int) $_GET ['page'] : 1;
        $offset = $pagesize * ($page - 1);
        $sql1 = "select count(*) AS num 
           FROM `".table('deposit')."` a
           LEFT JOIN `".table('member')."` b ON a.userid = b.id
           WHERE $where ";
        $result1 = SDB::query($sql1);
        $r1 = SDB::fetch_array($result1);
        $number = $r1['num'];
        $sql = "SELECT a.*,b.user,b.realname
           FROM `".table('deposit')."` a
           LEFT JOIN `".table('member')."` b ON a.userid = b.id
           WHERE $where ORDER BY `a`.`add_time` desc LIMIT $offset, $pagesize";
        $result = SDB::query($sql);
        while ($r = SDB::fetch_array($result))
        {
            $r['realname']=str_replace($keyword,"<b class='color-1'>".$keyword."</b>",$r['realname']);
            if ($r['paytype']==4)
            {
                $r['pay_type_name'] ='支付宝充值';
            } elseif($r['paytype']==1)
            {
                $r['pay_type_name'] ='微信扫码充值';
            }elseif ($r['paytype']==2){
                $r['pay_type_name'] ='微信公众号充值';
            }elseif ($r['paytype']==5){
                $r['pay_type_name'] ='微信APP充值';
            }else{
                $r['pay_type_name'] ='--';
            }
            $list[] = $r;
        }
        include admin_tpl('depositlists','mingxi');
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值