• ecshop学习三


    1.分页(留言列表实例)
    if ($_REQUEST['act'] == 'list')
    {
        $smarty->assign('full_page',  1);
        $smarty->assign('ur_here',     $_LANG['msg_list']);
        $smarty->assign('action_link', array('text' => $_LANG['send_msg'], 'href' => 'message.php?act=send'));
    
        $list = get_message_list();
    function get_message_list()
    {
        /* 查询条件 */
        $filter['sort_by']    = empty($_REQUEST['sort_by'])    ? 'sent_time' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
        $filter['msg_type']   = empty($_REQUEST['msg_type'])   ? 0 : intval($_REQUEST['msg_type']);
    
        /* 查询条件 */
        switch ($filter['msg_type'])
        {
            case 1:
                $where = " a.receiver_id='" .$_SESSION['admin_id']. "'";
                break;
            case 2:
               $where = " a.sender_id='".$_SESSION['admin_id']."' AND a.deleted='0'";
               break;
            case 3:
               $where = " a.readed='0' AND a.receiver_id='".$_SESSION['admin_id']."' AND a.deleted='0'";
               break;
            case 4:
               $where = " a.readed='1' AND a.receiver_id='".$_SESSION['admin_id']."' AND a.deleted='0'";
               break;
            default:
               $where = " (a.receiver_id='".$_SESSION['admin_id']."' OR a.sender_id='" .$_SESSION['admin_id']. "') AND a.deleted='0'";
        }
    
        $sql = "SELECT COUNT(*) FROM ".$GLOBALS['ecs']->table('admin_message')." AS a WHERE 1 AND ". $where;
        $filter['record_count'] = $GLOBALS['db']->getOne($sql);    //总记录数
    
        /* 分页大小 */
        $filter = page_and_size($filter);
    
        $sql = "SELECT a.message_id,a.sender_id,a.receiver_id,a.sent_time,a.read_time,a.deleted,a.title,a.message,b.user_name".
                " FROM ".$GLOBALS['ecs']->table('admin_message')." AS a,".$GLOBALS['ecs']->table('admin_user')." AS b ".
                " WHERE a.sender_id=b.user_id AND $where ".
                " ORDER BY ".$filter['sort_by']." ".$filter['sort_order'].
                " LIMIT ". $filter['start'] .", $filter[page_size]";
        $row = $GLOBALS['db']->getAll($sql);
    
        foreach ($row AS $key=>$val)
        {
            $row[$key]['sent_time'] = local_date($GLOBALS['_CFG']['time_format'], $val['sent_time']);//格式化时间
            $row[$key]['read_time'] = local_date($GLOBALS['_CFG']['time_format'], $val['read_time']);
        }
    
        $arr = array('item' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
    
        return $arr;
    }
    

      

    $smarty->assign('message_list', $list['item']);
    $smarty->assign('filter', $list['filter']);
    $smarty->assign('record_count', $list['record_count']);
    $smarty->assign('page_count', $list['page_count']);
    $sort_flag = sort_flag($list['filter']); //点击上下的图片
    $smarty->assign($sort_flag['tag'], $sort_flag['img']);
    assign_query_info();
    $smarty->display('message_list.htm'); }

     

      <table cellpadding="4" cellspacing="0">
        <tr>
          <td><input type="submit" name="drop" id="btnSubmit" value="{$lang.drop}" class="button" disabled="true" /></td>
          <td align="right">{include file="page.htm"}</td>
        </tr>
      </table>
    
          <!-- $Id: page.htm 14216 2008-03-10 02:27:21Z testyang $ -->
          {insert_scripts files="../js/utils.js"}
          <div id="turn-page">
            {$lang.total_records} <span id="totalRecords">{$record_count}</span>
            {$lang.total_pages} <span id="totalPages">{$page_count}</span>
            {$lang.page_current} <span id="pageCurrent">{$filter.page}</span>
            {$lang.page_size} <input type='text' size='3' id='pageSize' value="{$filter.page_size}" onkeypress="return listTable.changePageSize(event)" />
            <span id="page-link">
              {literal}<a href="javascript:listTable.gotoPageFirst()">{/literal}{$lang.page_first}</a>
              {literal}<a href="javascript:listTable.gotoPagePrev()">{/literal}{$lang.page_prev}</a>
              {literal}<a href="javascript:listTable.gotoPageNext()">{/literal}{$lang.page_next}</a>
              {literal}<a href="javascript:listTable.gotoPageLast()">{/literal}{$lang.page_last}</a>
              <select id="gotoPage" onchange="listTable.gotoPage(this.value)">
                {create_pages count=$page_count page=$filter.page}
              </select>
            </span>
          </div>
    

      

      

     

  • 相关阅读:
    js中的replace替换全部
    Oracle中创建数据链
    Hbuildx+vue+axios+element ui初学部署
    html5抠图
    Oracle误删除数据的恢复方法
    vs 生成项目自动关闭当前运行程序
    Mvc项目在iis上面显示文件夹 输入地址页面也打不开
    FastReport快速打印(.net)
    脚本之家
    VS自定义作者、创建时间
  • 原文地址:https://www.cnblogs.com/fengzhiqiangcaisangzi/p/3432560.html
Copyright © 2020-2023  润新知