ホームページ  >  記事  >  バックエンド開発  >  thinkphp のテキスト フィルター フィールドはすべて 1 つのテーブルにあります

thinkphp のテキスト フィルター フィールドはすべて 1 つのテーブルにあります

WBOY
WBOYオリジナル
2016-06-23 13:49:051165ブラウズ





プログラムコード

	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(); // 输出模板	}


フィルタリングする場所
<dt>招聘职位:</dt><a href="#" >全部</a><volist name="list" id="vo">	<a href="/index.php/Zhaopin/index/Position/{$vo[Position]}">{$vo['Position']}</a>	</volist> <dt>区域:</dt><a href="停车场.html">全深圳</a> <volist name="list" id="vo">	<a href="/index.php/Zhaopin/index/Recruitment/{$vo[Recruitment]}">{$vo['Recruitment']}</a>	</volist> 


コンテンツコード
<volist name="list" id="vo">	<span class="jobname" style="width:35%;"><a href="/index.php/Zhaopin/show/id/{$vo[id]}">{$vo['Job']|mb_substr=0,8,'UTF-8'}</a></span>	<span style="width:30%;"><a href="/index.php/Zhaopin/show/id/{$vo[id]}">{$vo['company_name']}</a></span>	<span style="width:16%;">{$vo['Recruitment']}</span>	<span style="width:15%;">{$vo['shijian']}</span>			招聘人数:{$vo['hiring']}人    			公司性质:{$vo['Nature']}    			规模:{$vo['company_scale']}人    			经验:{$vo['Work_experience']}年    			学历:{$vo['Degree_required']}    			职位月薪:{$vo['salary']}元/月		岗位要求: {$vo['Job_requirements']|mb_substr=0,150,'UTF-8'}	<a href="/index.php/Zhaopin/show/id/{$vo[id]}" class="getjob">查看职位</a></dd></volist>


ディスカッションへの返信 (解決策)

主な質問は書けない中の様子

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(); // 输出模板}

おそらく次のようになります。

45a2772a6b6107b401db3c9b82c049c2 を削除して赤色を追加したかったのですが、結局 PHP コード ブロックに入れてしまいました。 。 。

その場合は、ページングを配列ページングに変更できます。

$count=count($list);$Page       = new \Think\Page($count,20);$show       = $Page->show();// 分页显示输出$data=array_slice($list,$Page->firstRow,$Page->listRows);$this->assign("list",$data);

クエリ条件を書く場所

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(); // 输出模板}

こんな感じです、参考になるか確認してください




2c7953a8f6f793cfefe6eaa0b0257de73499910bf9dac5ae3c52d5ede7383485{$vo [' Position']}5db79b134e9f6b82c0b36e0489ee08ed23813f5caa5bd6f61f2579e4b5e0383e_param('Recruitment'); // パラメータを受け取る価値はありますか? ? ? ?

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。