当前位置:Gxlcms > PHP教程 > thinkphp文字罗选字段都在一个表里面

thinkphp文字罗选字段都在一个表里面

时间:2021-07-01 10:21:17 帮助过:11人阅读

thinkphp 文字 筛选 字段 都在一个表里面




程序代码

public function index(){
$Data = M('zhaopin'); // 实例化Data数据对象
import('ORG.Util.Page');// 导入分页类
$count= $Data->where($map)->count();// 查询满足要求的总记录数
$Page= new Page($count,20);// 实例化分页类 传入总记录数
$nowPage = isset($_GET['p'])?$_GET['p']:1;
$list = $Data->where($map)->order('shijian desc,id asc')->page($nowPage.','.$Page->listRows)->select();
$show = $Page->show();// 分页显示
输出
$this->assign('count',$count);
$this->assign('page',$show);// 赋值分页输出
$this->assign('list',$list);// 赋值数据集
$this->display(); // 输出模板
}


筛选的地方

招聘职位:

全部

{$vo['Position']}

区域:

全深圳

{$vo['Recruitment']}



内容代码


{$vo['Job']|mb_substr=0,8,'UTF-8'}
{$vo['company_name']}
{$vo['Recruitment']}
{$vo['shijian']}
招聘人数:{$vo['hiring']}人
公司性质:{$vo['Nature']}
规模:{$vo['company_scale']}人
经验:{$vo['Work_experience']}年
学历:{$vo['Degree_required']}
职位月薪:{$vo['salary']}元/月
岗位要求: {$vo['Job_requirements']|mb_substr=0,150,'UTF-8'}
查看职位


------解决思路----------------------

public function index(){
$Data = M('zhaopin'); // 实例化Data数据对象
import('ORG.Util.Page');// 导入分页类

$map="1=1 ";//初始化条件变量
$Position=$this->_param('Position');//接收参数
$Recruitment=$this->_param('Recruitment');//接收参数
if($Position<>''){
$map.=" and Position='$Position'";
}
if($Recruitment<>''){
$map.=" and Recruitment='$Recruitment'";
}

$count= $Data->where($map)->count();// 查询满足要求的总记录数
$Page= new Page($count,20);// 实例化分页类 传入总记录数
$nowPage = isset($_GET['p'])?$_GET['p']:1;
$list = $Data->where($map)->order('shijian desc,id asc')->page($nowPage.','.$Page->listRows)->select();
$show = $Page->show();// 分页显示
输出
$this->assign('count',$count);
$this->assign('page',$show);// 赋值分页输出
$this->assign('list',$list);// 赋值数据集
$this->display(); // 输出模板
}

大概是这个样子,楼主看看是否有用

人气教程排行