?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
/**
*@brief 查询
****/
public function index(){
$choose = I('choose','-6');
$c['easy_hard'] = $choose;
$type=I('typeid','');
$nowpage=I('page',1);
if($type == '')
{
if($choose == -6)
{
$totalpage=ceil((D('data')->count())/10);
$infos=D('data')->limit(($nowpage-1)*10,10)->select();
}else{
$totalpage=ceil((D('data')->where($c)->count())/10);
$infos=D('data')->where($c)->limit(($nowpage-1)*10,10)->select();
}
}else{
if($choose == -6)
{
$map['data'] = array('like',"%$type%");
$totalpage=ceil((D('data')->where($map)->count())/10);
$infos=D('data')->where($map)->limit(($nowpage-1)*10,10)->select();
}else{
$map['data'] = array('like',"%$type%");
$totalpage=ceil((D('data')->where($map)->where($c)->count())/10);
$infos=D('data')->where($map)->where($c)->limit(($nowpage-1)*10,10)->select();
}
}
$this->assign('type',$type);
$this->assign('choose',$choose);
$this->assign("totalpage",$totalpage);
$this->assign("infos",$infos);
$this -> display();
}
}
!DOCTYPE html>
html lang="en">
head>
meta charset="UTF-8">
title>Think Demo/title>
script type="text/javascript" src="__PUBLIC__/jquery-1.11.1/jquery.min.js">/script>
script type="text/javascript" src="__PUBLIC__/jquery-1.11.1/jquery.js">/script>
script type="text/javascript" src="__PUBLIC__/layer/layer.js">/script>
script type="text/javascript" src="__PUBLIC__/laypage/laypage.js">/script>
/head>
body>
div>
select name="" id="slc1" onchange="return choose()">
option value="-6" if condition="$choose eq -6 "> selected /if> >全部/option>
option value="0" if condition="$choose eq 0 "> selected /if> >简单/option>
option value="1" if condition="$choose eq 1 "> selected /if> >一般/option>
/select>
input type="text" value="if condition="$type neq '' "> {$type} /if>" id="type">button id="sou">搜索/button>
/div>
br>
table border="1" width="500" height="150" >
tr>
th>ID/th>
th>语言/th>
th>难易程度/th>
th>操作/th>
/tr>
volist name="infos" id="vo">
tr>
th>{$vo.id}/th>
th>{$vo.data}/th>
th>
if condition="$vo.easy_hard eq '0'">简单
else />一般
/if>
/th>
th>
a href="javascript:;" rel="external nofollow" rel="external nofollow" )[1];
return '?'+firstParam+''+param+'='+value+''+lastPraam;
}else{
if(firstParam){
return '?'+firstParam+''+param+'='+value;
}else{
return '?'+param+'='+value;
}
}
}else{
if(query == ''){
return '?'+param+'='+value;
}else{
return '?'+query+''+param+'='+value;
}
}
}
/script>
/body>
/html>
更多关于thinkPHP相关内容感兴趣的读者可查看本站专题:《ThinkPHP入门教程》、《thinkPHP模板操作技巧总结》、《ThinkPHP常用方法总结》、《codeigniter入门教程》、《CI(CodeIgniter)框架进阶教程》、《Zend FrameWork框架入门教程》及《PHP模板技术总结》。