index.html:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="keywords" content="" />
<meta name="description" content="">
<meta name="author" content="">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp"/>
<link rel="icon" href="__PUBLIC__/images/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="__TMPL__Public/assets/images/favicon.ico" type="image/x-icon">
<link href="__PUBLIC__/css/zhifu.css" rel="stylesheet">
<script src="__PUBLIC__/js/jquery-1.11.3.min.js"></script>
</head>
<body>
<div class="logo_ou">
<img src="__TMPL__Public/assets/images/logo.jpg" />
</div>
<form action="__CONTROLLER__/index" method="post">
<div class="nav">
<div class="nav_d">选客服:</div>
<div class="nav_d nav_select">
<select name="nav_d_kf">
<option value="">不限</option>
<foreach name="k_w_t" item="kwt">
<option>{$kwt.post_kf}</option>
</foreach>
</select>
</div>
<div class="nav_d">选网编:</div>
<div class="nav_d nav_select">
<select name="nav_d_wb">
<option value="">不限</option>
<foreach name="k_w_t" item="kwt">
<option>{$kwt.post_wb}</option>
</foreach>
</select>
</div>
<div class="nav_d">选时间:</div>
<div class="nav_d nav_select">
<select name="nav_d_time">
<option value="">不限</option>
<foreach name="k_w_t" item="kwt">
<option>{$kwt.post_time}</option>
</foreach>
</select>
</div>
<div class="nav_d"><button class="button gray nav_sub_one" type="submit">查询</button></div>
<input class="nav_d_display" name="nav_d_type" value="0" />
</div>
</form>
<form action="__CONTROLLER__/index" method="post">
<div class="nav_two">
<div class="nav_d">搜索内容:</div>
<div class="nav_d nav_select"><input name="nav_d_select" type="text" /></div>
<div class="nav_d"><button class="button gray nav_sub_two" type="submit">搜索</button></div>
<input class="nav_d_display" name="nav_d_type" value="1" />
</div>
</form>
<div class="fenye"><div id="page_id_li">共 <span id="page_count">{$count}</span> 条</div>{$Page}</div>
<div class="h_content_wai">
<div class="h_content">
<div class="h_con_th">
<div class="h_con_th_li" style="width: 4%">顺序</div>
<div class="h_con_th_li" style="width: 7%">类型</div>
<div class="h_con_th_li" style="width: 7%">状态</div>
<div class="h_con_th_li" style="width: 19%">网站名称</div>
<div class="h_con_th_li" style="width: 17%">域名</div>
<div class="h_con_th_li" style="width: 5%">营销</div>
<div class="h_con_th_li" style="width: 5%">客服</div>
<div class="h_con_th_li" style="width: 5%">网编</div>
<div class="h_con_th_li" style="width: 10%">开始时间</div>
<div class="h_con_th_li" style="width: 10%">级别</div>
<div class="h_con_th_li" style="width: *;border-right: none">备注</div>
</div>
<foreach name="list" item="select">
<div class="h_con_th_two">
<div class="h_con_th_li_two" style="width: 4%">{$select.id}</div>
<div class="h_con_th_li_two" style="width: 7%">{$select.post_lx}</div>
<div class="h_con_th_li_two" style="width: 7%">{$select.post_zt}</div>
<div class="h_con_th_li_two" style="width: 19%">{$select.post_name}</div>
<div class="h_con_th_li_two" style="width: 17%"><a target="_blank" href="">{$select.post_ym}</a></div>
<div class="h_con_th_li_two" style="width: 5%">{$select.post_yx}</div>
<div class="h_con_th_li_two" style="width: 5%">{$select.post_kf}</div>
<div class="h_con_th_li_two" style="width: 5%">{$select.post_wb}</div>
<div class="h_con_th_li_two" style="width: 10%">{$select.post_time}</div>
<div class="h_con_th_li_two" style="width: 10%">{$select.post_jb}</div>
<div class="h_con_th_li_two" style="width: 10%;border-right:1px solid #ffffff;" title="{$select.post_bz}">{$select.post_bz}</div>
</div>
</foreach>
</div>
</div>
</body>
</html>
zhifu.css:
@charset "utf-8";
/* CSS Document */
*{
margin: 0px auto;
padding: 0px;
font-size: 14px;
font-family: "微软雅黑";
text-align: center;
color: #222222;
}
body{
padding-top:50px;
min-width: 1100px;
}
div,span{
cursor: default;
}
.logo_ou img{
width: 400px;
height: auto;
}
.nav{
height: 45px;
margin-top: 40px;
}
.nav_d{
display: inline;
height: 45px;
line-height: 45px;
}
.nav_select{
margin-right:20px;
}
.nav_d select,option{
width: 100px;
height: 25px;
line-height: 25px;
text-align: left;
}
.nav_d input{
width: 200px;
height: 25px;
line-height: 25px;
text-align: left;
}
.button{
width: 100px;
line-height: 25px;
text-align: center;
/*font-weight: bold;*/
color: #fff;
text-shadow:1px 1px 1px #333;
border-radius: 3px;
margin:0 20px 20px 0;
position: relative;
overflow: hidden;
}
.button.gray{
/*color: #555555;
text-shadow:1px 1px 1px #fff;*/
color: #ffffff;
border:1px solid #dce1e6;
box-shadow: 0 1px 2px #49a9de inset,0 -1px 0 #a8abae inset;
background: #45A1DE;
background: -webkit-linear-gradient(top,#45A1DE,#49a9de);
background: -moz-linear-gradient(top,#45A1DE,#49a9de);
background: linear-gradient(top,#45A1DE,#49a9de);
}
.nav_two{
margin-top: 10px;
}
.h_con_th{
width: 100%;
height: 37px;
background: #45A1DE;
}
.h_con_th_two{
width: 100%;
height: 37px;
border-bottom: 1px solid #cccccc;
}
.h_con_th_li{
float: left;
height: 37px;
line-height: 37px;
border-right: 1px solid #ffffff;
background: #45A1DE;
color: #ffffff;
text-align: left;
text-indent: 7px;
overflow: hidden;
font-weight: bold;
}
.h_con_th_li_two{
float: left;
height: 37px;
line-height: 37px;
border-right: 1px solid #cccccc;
text-align: left;
text-indent: 7px;
overflow: hidden;
}
.h_con_th_li_two a{
color: blue;
}
.h_con_th_li_two a:hover{
color: blue;
}
.h_content{
border-top: 1px solid #dddddd;
}
.nav_d_display{
display: none;
}
/*分页代码*/
.fenye{
margin-top: 8px;
margin-bottom: 25px;
}
.fenye div{
display: inline;
}
#page_count{
color:#ffffff;
margin: 0px 5px;
}
.fenye div a{
text-decoration: none;
display: inline-block;
padding: 2px 8px;
height: 19px;
line-height: 19px;
background: #45A1DE;
color: #ffffff;
font-size: 12px;
margin: 0px 2px;
}
.fenye div a:hover{
color: #ffffff;
background: #888888;
}
.fenye div span{
text-decoration: none;
display: inline-block;
padding: 2px 8px;
height: 19px;
line-height: 19px;
background: #888888;
color: #ffffff;
font-size: 12px;
margin: 0px 2px;
}
#page_id_li{
margin-right: 15px;
}
IndexController.class.php:
<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){
$npost = array_merge($_GET,$_POST);//$_POST接收传过来的条件搜索、$_GET接收p=x(第几页)
//var_dump($npost);die();
$Wxch_indent = M("posts"); // 实例化Wxch_indent对象
//import('ORG.Util.Page'); //Page类的引入
$k_w_t = $Wxch_indent->distinct(true)->field('post_kf,post_wb,post_time')->select();//给post_kf,post_wb,post_time这三个字段去重,在前台模版中循环输出<option></option>,实现select选项的动态化
if($npost['nav_d_type'] == 0){
//如果$npost['nav_d_type']传过来的值为0,就是走第一个搜索条件
$where['post_kf'] = $npost['nav_d_kf'];
$where['post_wb'] = $npost['nav_d_wb'];
$where['post_time'] = $npost['nav_d_time'];
$where['_logic'] = 'OR';
if(empty($npost['nav_d_kf']) && empty($npost['nav_d_wb']) && empty($npost['nav_d_time']) && empty($npost['nav_d_select'])){//搜索条件如果为空显示全部数据
$count = $Wxch_indent->count();// 查询满足要求的总记录数
$Page = $page = new \Think\Page($count, 5,$npost);//实例化page类,传入数据总数和每页显示10条内容,$npost为查询条件,在分页中带入条件
$show = $Page->show();// 分页显示输出
// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
$list = $Wxch_indent->order('id asc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
}else{
$count = $Wxch_indent->where($where)->count();// 查询满足要求的总记录数
$Page = $page = new \Think\Page($count, 5,$npost);//实例化page类,传入数据总数和每页显示10条内容,$npost为查询条件,在分页中带入条件
$show = $Page->show();// 分页显示输出
$list = $Wxch_indent->where($where)->order('id asc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
}
$this->assign('count',$count);//总条数或分页后总条数显示
$this->assign('k_w_t',$k_w_t);//去重后的post_kf,post_wb,post_time字段包含的所有数据
$this->assign('list',$list);// 赋值数据集
$this->assign('Page',$show);// 赋值分页输出
$this->show();//在index页面显示输出
}else if($npost['nav_d_type'] ==1){
//如果$npost['nav_d_type']传过来的值为1,就是走第二个搜索条件
$where['post_lx'] = array('like', "%{$npost['nav_d_select']}%");
$where['post_kf'] = array('like', "%{$npost['nav_d_select']}%");
$where['post_wb'] = array('like', "%{$npost['nav_d_select']}%");
$where['post_yx'] = array('like', "%{$npost['nav_d_select']}%");
$where['post_ym'] = array('like', "%{$npost['nav_d_select']}%");
$where['post_jb'] = array('like', "%{$npost['nav_d_select']}%");
$where['post_bz'] = array('like', "%{$npost['nav_d_select']}%");
$where['post_time'] = array('like', "%{$npost['nav_d_select']}%");
$where['post_name'] = array('like', "%{$npost['nav_d_select']}%");
$where['_logic'] = 'OR';
if(empty($npost['nav_d_select'])){//搜索条件如果为空显示全部数据
$count = $Wxch_indent->count();// 查询满足要求的总记录数
$Page = $page = new \Think\Page($count, 5,$npost);//实例化page类,传入数据总数和每页显示10条内容,$npost为查询条件,在分页中带入条件
$show = $Page->show();// 分页显示输出
// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
$list = $Wxch_indent->order('id asc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
}else{
$count = $Wxch_indent->where($where)->count();// 查询满足要求的总记录数
$Page = $page = new \Think\Page($count, 5,$npost);//实例化page类,传入数据总数和每页显示10条内容,$npost为查询条件,在分页中带入条件
$show = $Page->show();// 分页显示输出
$list = $Wxch_indent->where($where)->order('id asc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
}
$this->assign('count',$count);//总条数或分页后总条数显示
$this->assign('k_w_t',$k_w_t);//去重后的post_kf,post_wb,post_time字段包含的所有数据
$this->assign('list',$list);// 赋值数据集
$this->assign('Page',$show);// 赋值分页输出
$this->show();//在index页面显示输出
}
}
}
——————————————