zoukankan      html  css  js  c++  java
  • ecshop 分页小记

    ecshop 分页是ajax请求的,必须在主文件里有个 act = query 处理,分页会请求这个act

    <?php
    //获取列表
    if($_REQUEST['act']=='list'){
        
        //权限设置
       admin_priv('issued_invite_code');
        
        $res = get_list();
       
        $smarty-> assign('list',$res['list']);
        $smarty-> assign('filter',       $res['filter']);
        $smarty-> assign('record_count', $res['filter']['record_count']);
        $smarty-> assign('page_count',   $res['filter']['page_count']);
        
        assign_query_info();
        $smarty->display('aa.html');
    }
    
    
    //分页ajax查询
    if($_REQUEST['act'] == 'query'){
        
        admin_priv('issued_invite_code');
        
        $list = get_list();
         
        $smarty-> assign('list',$res['list']);
        $smarty-> assign('filter',       $res['filter']);
        $smarty-> assign('record_count', $res['filter']['record_count']);
        $smarty-> assign('page_count',   $res['filter']['page_count']);
        
        $smarty->assign('is_ajax' ,true);
        
        assign_query_info();
        make_json_result($smarty->fetch('aa.html'), '',
            array('filter' => $res['filter'], 'page_count' => $res['filter']['page_count']));   
    }
    
    function get_list(){
        
        $filter['record_count'] = $GLOBALS['db']->getOne("select count(*) from aa");
        $filter = page_and_size($filter);
        
        $sql = "select * from aa  LIMIT  $filter[start] , $filter[page_size]";
        
        $list = $GLOBALS['db']-> getAll($sql);
        
        return array('list'=>$list,'filter'=>$filter);
    }
    
    ?>
    {insert_scripts files="jquery.js,jquery.json.js,../js/transport.js,common.js"}  //引入 必要的js
    {insert_scripts files="../js/utils.js,listtable.js"}      //引入 listtable.js
    
     {if !$is_ajax}     //如果是ajax分页就不显示表头
        <h2 class="go-list">下发记录</h2>
     {/if}
     
    <div class="list-div" id="listDiv">
        <table cellpadding="3" cellspacing="1">
          <tr>
            <th>id</th>
            <th>名称</th>
          </tr>
          {if $list}
             {foreach from=$list item=data}
                <tr>
                <td style="background-color: rgb(255, 255, 255);text-align: center;">{$data.id}</td>
                <td style="background-color: rgb(255, 255, 255);text-align: center;">{$data.name}</td>
              </tr>
             {/foreach}
         {else}
             <tr>
                <td>记录为空</td>
             </tr>
         {/if}
        </table>
    
        <table cellpadding="4" cellspacing="0">
            <tr>
                <td align="right">{include file="page.htm"}</td>      //引入分页模板
            </tr>
        </table>
    </div>
  • 相关阅读:
    二叉搜索树与双向链表
    TCP 三次握手与四次挥手
    复杂链表的复制
    二叉树中和为某一值的路径
    二叉搜索树的后序遍历序列
    从上往下打印二叉树
    栈的压入、弹出序列
    jenkins 持续集成和交付——一个构件小栗子前置(三)
    jenkins 持续集成和交付——gogs安装(外篇)
    jenkins 持续集成和交付——安装与账户安全还有凭证(二)
  • 原文地址:https://www.cnblogs.com/dhsx/p/5477045.html
Copyright © 2011-2022 走看看