• php 原生分页(2)


    <?php

    require 'common.php';
    error_reporting(E_ALL);
    date_default_timezone_set('PRC');

    //判断登录
    if (!isset($_SESSION['uname']) || empty($_SESSION['uname'])) {
    header("Location: login.php");
    }


    $wherelist=array();
    $urlist=array();
    //搜索标题
    if(!empty($_GET['subject']))
    {
    $wherelist[]=" subject like '%".$_GET['subject']."%'";
    $urllist[]="subject=".$_GET['subject'];

    }
    //搜索发件人
    if(!empty($_GET['from_email']))
    {
    // var_dump($_GET['from_email']);die();
    $wherelist[]=" from_email like '%".$_GET['from_email']."%'";
    $urllist[]="from_email=".$_GET['from_email'];
    }

    if(!empty($_GET['to_email']))
    {
    $wherelist[]=" to_email like '%".$_GET['to_email']."%'";
    $urllist[]="to_email=".$_GET['to_email'];
    }

    $start_time = $end_time = 0;
    if(!empty($_GET['start_time'])){
    $start_time = strtotime($_GET['start_time']);
    }
    if(!empty($_GET['end_time'])){
    $end_time = strtotime($_GET['end_time']);
    }
    //如果结束时间比开始时间大
    if($end_time > $start_time){
    $wherelist[] = " create_time >=".$start_time." and create_time <=".$end_time;

    $urllist[]="start_time=".$_GET['start_time'];
    $urllist[]="end_time=".$_GET['end_time'];
    }
    //如果结束时间和开始时间一样大
    if(($end_time==$start_time)&&($end_time>0)&($start_time>0)){
    //查询当天的数据
    $s = strtotime(date('Y-m-d',$start_time));
    $e = $s+86400;

    $wherelist[] = " create_time >=".$s." and create_time <=".$e;
    $urllist[]="start_time=".$_GET['start_time'];
    $urllist[]="end_time=".$_GET['end_time'];
    }


    $where="";
    if(count($wherelist)>0)
    {
    $where =" where ".implode(' and ',$wherelist);
    $url='&'.implode('&',$urllist);

    }

    //计算总条数
    $sql = "select * from mail_send $where";
    $result = mysql_query($sql);

    // $map = isset($where)?$where:'where 1';
    if(empty($where)){
    $map = 'where status = 2';
    }else{
    $map = $where;
    $map.= ' and status = 2';

    }
    $sql2 = "select * from mail_send $map";
    $success = mysql_num_rows(mysql_query($sql2));
    $totalnum = mysql_num_rows($result);
    //每页显示条数
    $pagesize = 10;
    //总共有几页
    $maxpage=ceil($totalnum/$pagesize);
    $page = 1;
    $p = (int)$_GET['page'];
    if($p>0){
    $page = $p;
    }


    if($page>$maxpage)
    {
    $page=$maxpage;
    }
    $a = $page-1;

    $limit = " limit ".($page-1)*$pagesize.",$pagesize";
    $sql1 = "select * from mail_send {$where} order by id desc {$limit}";
    $res = mysql_query($sql1);
    // $sql = mysql_query("select * from mail_send where user_id=12689 order by id desc", $conn);
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>中宏保险</title>
    <script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
    <style type="text/css">
    body,html{
    padding: 0px;
    margin: 0px;
    }
    .header {
    100%;
    padding: 0px;
    margin: 0px;
    background-color: #699C03;
    }

    .header-nav {
    min- 1170px;

    height: 50px;
    line-height: 50px;
    }

    .header-nav-left {
    float: left;
    padding-left: 150px;
    margin-top: 10px;
    }

    .header-nav-left h3 {
    font-size: 18px;
    line-height: 25px;
    margin: 0px;
    color: #fff;
    }

    .header-nav-right {
    float: right;
    59.9999%;
    position: relative;
    height: 50px;
    }

    .header-nav-right ul {
    padding: 0px;
    margin: 0px;
    list-style: none;
    position: absolute;
    right: 25px;
    }

    .header-nav-right ul li {
    float: left;
    margin-left: 5px;
    color: #fff;
    }

    .header-nav-right ul li a {
    color: #fff;
    text-decoration: none;

    }
    </style>
    <!-- 后台组件样式 引入 -->
    <link rel="stylesheet" href="https://unpkg.com/fast-admin@latest/fast-admin.css">
    </head>
    <body>
    <div class="header">
    <div class="header-nav">
    <div class="header-nav-left">
    <h3>中宏保险</h3>
    </div>
    <div class="header-nav-right">
    <ul>
    <li><span>欢迎到来到网站后台</span></li>
    <li><a href="/">群发</a></li>

    <li><a href="tr.php">触发</a></li>
    <li><a href="">退出</a></li>
    </ul>
    </div>
    </div>
    </div>

    <!-- 正文内容 start -->
    <div style=" 95%;margin: auto;">

    <!-- 表单搜索 start -->
    <form action="/tr.php" method="get" class="mo-form mo-form--inline" >
    <div class="mo-form-item">
    <span class="mo-form-item-label">标题:</span>
    <span class="mo-form-item-form">
    <input name="subject" value="<?php echo $_GET['subject']?>" type="text" class="mo-input" placeholder="输入标题">
    </span>
    </div>
    <div class="mo-form-item">
    <span class="mo-form-item-label">发件人邮箱:</span>
    <span class="mo-form-item-form">
    <input name="from_email" value="<?php echo $_GET['from_email']?>" type="email" class="mo-input" placeholder="输入发件人邮箱">
    </span>
    </div>
    <div class="mo-form-item">
    <span class="mo-form-item-label">收件人邮箱:</span>
    <span class="mo-form-item-form">
    <input name="to_email" value="<?php echo $_GET['to_email']?>" type="email" class="mo-input" placeholder="输入收件人邮箱">
    </span>
    </div><br/>
    <div class="mo-form-item">
    <span class="mo-form-item-label">开始时间:</span>
    <span class="mo-form-item-form">
    <!-- <input name="start_time" type="text" class="mo-input" placeholder="输入开始时间"> -->
    <span
    data-time-name="start_time"
    data-time-value="<?php echo $_GET['start_time']?>"
    ></span>
    </span>
    </div>
    <div class="mo-form-item">
    <span class="mo-form-item-label">结束时间:</span>
    <span class="mo-form-item-form">
    <!-- <input name="end_time" type="text" class="mo-input" placeholder="输入结束时间"> -->
    <span
    data-time-name="end_time"
    data-time-value="<?php echo $_GET['end_time']?>"
    ></span>
    </span>
    </div>
    <input type="submit" value="搜索">
    </form>
    <br/>
    <!-- 表单搜索 start -->

    <!-- 列表显示 start -->
    <div class="mo-box-bd">

    <!-- table start -->
    <div class="mo-tableScroll">
    <table class="mo-table">
    <thead>
    <tr>
    <th>标题</th>
    <th>发件人</th>
    <th>发件人邮箱</th>
    <th>收件人邮箱</th>
    <th>回复邮箱</th>
    <th>发送时间</th>
    <th>状态</th>
    <th>模板</th>
    </tr>
    </thead>
    <tbody>
    <?php while ($row= mysql_fetch_assoc($res)){ ?>
    <tr>
    <td><?php echo $row['subject']; ?></td>
    <td><?php echo $row['fromname']; ?></td>
    <td><?php echo $row['from_email']; ?></td>
    <td><?php echo $row['to_email']; ?></td>
    <td><?php echo $row['replyto']; ?></td>
    <td><?php echo date('Y-m-d H:i:s', $row['create_time']); ?></td>
    <td>
    <?php echo $row['status'] == 2 ? '发送成功' : ($row['status'] == 1 ? '待发送' : '发送失败'); ?></td>
    </td>
    <td>
    <a href="/look.php?id=<?php echo $row['id']; ?>"
    class="mo-btn mo-btn--link"
    >查看</a>
    </td>
    </tr>
    <?php } ?>
    </tbody>
    </table>
    </div>
    <!-- table end -->

    <!-- 分页 start -->
    <div class="mo-paging">
    <span class="mo-paging-info">
    <?php echo " 当前{$page}/{$maxpage}页 共{$totalnum}条" ; ?>
    </span>

    <a class="mo-paging-prev"
    href="/tr.php?page=<?php echo ($page-1) ?><?php echo $url;?>"
    >
    <i class="fa fa-angle-left" title="左三角形"></i> 上一页
    </a>



    <a href="/tr.php?page=1"
    <?php
    if($_GET['page']==1){
    echo 'class="mo-paging-item mo-paging-current"';
    }else{
    echo 'class="mo-paging-item"';
    }
    ?>
    >1</a>

    <a href="/tr.php?page=2"
    <?php
    if($_GET['page']==2){
    echo 'class="mo-paging-item mo-paging-current"';
    }else{
    echo 'class="mo-paging-item"';
    }
    ?>
    >2</a>

    <a href="/tr.php?page=3"
    <?php
    if($_GET['page']==3){
    echo 'class="mo-paging-item mo-paging-current"';
    }else{
    echo 'class="mo-paging-item"';
    }
    ?>
    >3</a>

    <a href="/tr.php?page=4"
    <?php
    if($_GET['page']==4){
    echo 'class="mo-paging-item mo-paging-current"';
    }else{
    echo 'class="mo-paging-item"';
    }
    ?>
    >4</a>
    <span class="mo-paging-ellipsis">...</span>

    <?php if($page>4){?>
    <a href="/tr.php?page=<?php echo $page;?>"
    class="mo-paging-item mo-paging-current"
    ><?php echo $page;?>
    <a href="/tr.php?page=<?php echo ($page+1);?>"
    class="mo-paging-item"
    ><?php echo ($page+1);?>
    <a href="/tr.php?page=<?php echo ($page+2);?>"
    class="mo-paging-item"
    ><?php echo ($page+2);?>
    <a href="/tr.php?page=<?php echo ($page+3);?>"
    class="mo-paging-item"
    ><?php echo ($page+3);?>
    </a>
    <?php }?>


    <!-- <a href="/tr.php?page=2" class="mo-paging-item mo-paging-current">2</a>
    <a href="/tr.php?page=3" class="mo-paging-item">3</a>
    <a href="/tr.php?page=4" class="mo-paging-item">4</a>
    <span class="mo-paging-ellipsis">...</span>
    <a href="/tr?page=24" class="mo-paging-item">24</a> -->

    <a href="/tr.php?page=<?php echo ($page+1) ?><?php echo $url;?>"
    class="mo-paging-next">
    下一页 <i class="fa fa-angle-right" title="右三角形"></i>
    </a>
    <span class="mo-paging-info">
    <span class="mo-paging-bold">
    <?php echo '成功条数:'.$success; ?>
    </span>
    </span>
    </div>
    <!-- 分页 end -->

    </div>
    <!-- 列表显示 end -->

    </div>
    <!-- 正文内容 end -->


    <!-- fast-admin js 文件引入 -->
    <script src="https://unpkg.com/fast-admin@latest/fast-admin-deps.js"></script>
    <script src="https://unpkg.com/fast-admin@latest/fast-admin.js"></script>
    </body>
    </html>

  • 相关阅读:
    emoji表情,直接存入数据库报错,,出现java.sql.SQLException: Incorrect string value: 'xF0x9Fx98x8ExF0。。。。。。
    Springmvc的服务端数据验证-----Hibernate Validator
    HashMap
    Treeset的两种排序方法(自然排序和比较器排序)
    Java设计模式之适配器模式
    Java中的三种工厂模式
    构造方法私有化_骰子
    Java中equals的覆盖
    HttpClient请求
    JAVA的单例模式与延时加载
  • 原文地址:https://www.cnblogs.com/ayanboke/p/8818370.html
Copyright © 2020-2023  润新知