编程是要偷懒的--option简练写法
没改前:
if(!empty($search)){
$where['personal_name'] = array('like','%'. $search . '%');
$this -> assign('search',$search);
}
if(!empty($category)){
if($category == "请选择职位") $category=null;
$where['category_name'] = array('like','%'. $category . '%');
// $where['category_name'] = $category;
$this -> assign('category',$category);
}
if(!empty($type)){
switch ($type){
case "请选择简历类型":
$type = null;
break;
case "全职":
$where['resume_type'] = 1;
break;
case "兼职":
$where['resume_type'] = 2;
break;
default:break;
}
$this -> assign('type',$type);
}
if(!empty($education)){
switch($education){
case "请选择个人学历":
// $education = null;
break;
case "不限":
// $where['personal_education'] = 0;
break;
case "初中及以下":
$where['personal_education'] = 1;
break;
case "高中":
$where['personal_education'] = 2;
break;
case "中技/中专":
$where['personal_education'] = 3;
break;
case "大专":
$where['personal_education'] = 4;
break;
case "本科":
$where['personal_education'] = 5;
break;
case "硕士":
$where['personal_education'] = 6;
break;
case "MBA/EMBA":
$where['personal_education'] = 7;
break;
case "博士":
$where['personal_education'] = 8;
break;
case "博士后":
$where['personal_education'] = 9;
break;
default:break;
}
$this -> assign('education',$education);
}
if(!empty($working)){
switch($working){
case "请选择个人工作年限":
// $where['personal_working'] = 0;
break;
case "不限":
// $where['personal_working'] = 0;
break;
case "1年以下":
$where['personal_working'] = 1;
break;
case "1-2年":
$where['personal_working'] = 2;
break;
case "3-5年":
$where['personal_working'] = 3;
break;
case "6-7年":
$where['personal_working'] = 4;
break;
case "8-10年":
$where['personal_working'] = 5;
break;
case "10年以上":
$where['personal_working'] = 6;
break;
default:break;
}
$this -> assign('working',$working);
}
if(!empty($sex)){
switch($sex){
case "不限":
//
break;
case "男":
$where['personal_sex'] = 1;
break;
case "女":
$where['personal_sex'] = 2;
break;
default: break;
}
$this -> assign('sex',$sex);
}
html:
<form method="get">
<select class="button text" style="background-color: white; color: #428bca;" name="category">
<option>请选择职位</option>
<foreach name='select_name' item='v' >
<option <if condition="($category eq $v[category_name])">selected="selected"</if> >{$v.category_name}</option>
</foreach>
</select>
<select class="button text" style="background-color: white; color: #428bca;" name="type">
<option>请选择简历类型</option>
<option <if condition="($type eq 全职)">selected="selected"</if> > 全职</option>
<option <if condition="($type eq 兼职)">selected="selected"</if> >兼职</option>
</select>
<select class="button text" style="background-color: white; color: #428bca;" name="education">
<option>请选择个人学历</option>
<option <if condition="($education eq 不限)">selected="selected"</if> >不限</option>
<option <if condition="($education eq 初中及以下)">selected="selected"</if> >初中及以下</option>
<option <if condition="($education eq 高中)">selected="selected"</if> >高中</option>
<option <if condition="($education eq '中技/中专')">selected="selected"</if> >中技/中专</option>
<option <if condition="($education eq 大专)">selected="selected"</if> >大专</option>
<option <if condition="($education eq 本科)">selected="selected"</if> >本科</option>
<option <if condition="($education eq 硕士)">selected="selected"</if> >硕士</option>
<option <if condition="($education eq MBA)">selected="selected"</if> >MBA/EMBA</option>
<option <if condition="($education eq 博士)">selected="selected"</if> >博士</option>
<option <if condition="($education eq 博士后)">selected="selected"</if> >博士后</option>
</select>
<select class="button text" style="background-color: white; color: #428bca;" name="working">
<option>请选择个人工作年限</option>
<option <if condition="($working eq 不限)">selected="selected"</if> >不限</option>
<option <if condition="($working eq '1年以下')">selected="selected"</if> >1年以下</option>
<option <if condition="($working eq '1-2年')">selected="selected"</if> >1-2年</option>
<option <if condition="($working eq '3-5年')">selected="selected"</if> >3-5年</option>
<option <if condition="($working eq '6-7年')">selected="selected"</if> >6-7年</option>
<option <if condition="($working eq '8-10年')">selected="selected"</if> >8-10年</option>
<option <if condition="($working eq '10年以上')">selected="selected"</if> >10年以上</option>
</select>
<select class="button text" style="background-color: white; color: #428bca;" name="sex">
<option>请选择性别</option>
<option <if condition="($sex eq 不限)">selected="selected"</if> >不限</option>
<option <if condition="($sex eq 男)">selected="selected"</if> >男</option>
<option <if condition="($sex eq 女)">selected="selected"</if> >女</option>
</select>
<div class="btn-group"></div>
<input type="text" class="search" placeholder="请输入个人姓名" name="search" value="{$search}" style="margin-left: 1%;"/>
<input type="submit" value="搜索" class=" text button" style="border: none; float: none; margin-left: 1%;" />
</form>
修改后:
$type_array = array("请选择简历类型","全职","兼职");
$education_array = array("请选择个人学历","不限","初中及以下","高中","中技/中专","大专","本科","硕士","MBA/EMBA","博士","博士后");
$working_array = array("请选择个人工作年限","不限","1年以下","1-2年","3-5年","6-7年","8-10年","10年以上");
$sex_array = array("不限","男","女"); if(!empty($search)){
$where['personal_name'] = array('like','%'. $search . '%');
$this -> assign('search',$search);
}
if(!empty($category)){
if($category == "请选择职位") $category=null;
$where['category_name'] = array('like','%'. $category . '%');
$this -> assign('category',$category);
}
if(!empty($type)){
switch ($type){
case $type_array[0]:
$type = null;
break;
case $type_array[1]:
$where['resume_type'] = 1;
break;
case $type_array[2]:
$where['resume_type'] = 2;
break;
default:break;
}
$this -> assign('type',$type);
}
if(!empty($education)){
switch($education){
case $education_array[0]:
// $education = null;
break;
case $education_array[1]:
// $where['personal_education'] = 0;
break;
case $education_array[2]:
$where['personal_education'] = 1;
break;
case $education_array[3]:
$where['personal_education'] = 2;
break;
case $education_array[4]:
$where['personal_education'] = 3;
break;
case $education_array[5]:
$where['personal_education'] = 4;
break;
case $education_array[6]:
$where['personal_education'] = 5;
break;
case $education_array[7]:
$where['personal_education'] = 6;
break;
case $education_array[8]:
$where['personal_education'] = 7;
break;
case $education_array[9]:
$where['personal_education'] = 8;
break;
case $education_array[10]:
$where['personal_education'] = 9;
break;
default:break;
}
$this -> assign('education',$education);
}
if(!empty($working)){
switch($working){
case $working_array[0]:
// $where['personal_working'] = 0;
break;
case $working_array[1]:
// $where['personal_working'] = 0;
break;
case $working_array[2]:
$where['personal_working'] = 1;
break;
case $working_array[3]:
$where['personal_working'] = 2;
break;
case $working_array[4]:
$where['personal_working'] = 3;
break;
case $working_array[5]:
$where['personal_working'] = 4;
break;
case $working_array[6]:
$where['personal_working'] = 5;
break;
case $working_array[7]:
$where['personal_working'] = 6;
break;
default:break;
}
$this -> assign('working',$working);
}
if(!empty($sex)){
switch($sex){
case $sex_array[0]:
//
break;
case $sex_array[1]:
$where['personal_sex'] = 1;
break;
case $sex_array[2]:
$where['personal_sex'] = 2;
break;
default: break;
}
$this -> assign('sex',$sex);
} $this -> assign('type_array',$type_array);
$this -> assign('education_array',$education_array);
$this -> assign('working_array',$working_array);
$this -> assign('sex_array',$sex_array);
html:
<select class="button text" style="background-color: white; color: #428bca;" name="category">
<option>请选择职位</option>
<foreach name='select_name' item='v' >
<option <if condition="($category eq $v[category_name])">selected="selected"</if> >{$v.category_name}</option>
</foreach>
</select> <select class="button text" style="background-color: white; color: #428bca;" name="type">
<foreach name='type_array' item='v'>
<option <if condition="($type eq $v)">selected="selected"</if> >{$v}</option>
</foreach>
</select> <select class="button text" style="background-color: white; color: #428bca;" name="education">
<foreach name='education_array' item='v'>
<option <if condition="($education eq $v)">selected="selected"</if> >{$v}</option>
</foreach>
</select> <select class="button text" style="background-color: white; color: #428bca;" name="working">
<foreach name="working_array" item="v">
<option <if condition="($working eq $v)">selected="selected"</if> >{$v}</option>
</foreach>
</select> <select class="button text" style="background-color: white; color: #428bca;" name="sex">
<foreach name='sex_array' item='v'>
<option <if condition="($sex eq $v)">selected="selected"</if> >{$v}</option>
</foreach>
</select>
编程是要偷懒的
编程是要偷懒的--option简练写法的更多相关文章
- Javascript模块化编程(一):模块的写法
Javascript模块化编程(一):模块的写法 作者: 阮一峰 原文链接:http://www.ruanyifeng.com/blog/2012/10/javascript_module.html ...
- vb编程中的选择结构语句的写法
1996年,Bohra和Jacopin提出了结构化算法的3中种基本结构:顺序结构.选择结构和循环结构 目前已经得到证明,无论多么复杂的程序,都是由上面的3种基本结构中的一种或者多种的组合构成 在此笔者 ...
- Javascript模块化编程(一):模块的写法 (转)
Javascript模块化编程(一):模块的写法 原文作者: 阮一峰 日期: 2012年10月26日 随着网站逐渐变成"互联网应用程序",嵌入网页的Javascript代码越来越庞 ...
- Javascript模块化编程(一):模块的写法(转)
随着网站逐渐变成"互联网应用程序",嵌入网页的Javascript代码越来越庞大,越来越复杂. 网页越来越像桌面程序,需要一个团队分工协作.进度管理.单元测试等等......开发者 ...
- Javascript模块化编程(一):模块的写法 作者: 阮一峰
声明:转载自阮一峰的网络日志 随着网站逐渐变成"互联网应用程序",嵌入网页的Javascript代码越来越庞大,越来越复杂. 网页越来越像桌面程序,需要一个团队分工协作.进度管理. ...
- Javascript模块化编程(一):模块的写法 (转载 学习中。。。。)
转载地址:http://www.ruanyifeng.com/blog/2012/10/javascript_module.html 阮一峰 大神:http://www.ruanyifeng.com/ ...
- Javascript模块化编程(一):模块的写法【转】
作者: 阮一峰 日期: 2012年10月26日 随着网站逐渐变成"互联网应用程序",嵌入网页的Javascript代码越来越庞大,越来越复杂. 网页越来越像桌面程序,需要一个团队分 ...
- [转] Javascript模块化编程(一):模块的写法
随着网站逐渐变成"互联网应用程序",嵌入网页的Javascript代码越来越庞大,越来越复杂. 网页越来越像桌面程序,需要一个团队分工协作.进度管理.单元测试等等......开发者 ...
- (转)Javascript模块化编程(一):模块的写法
随着网站逐渐变成"互联网应用程序",嵌入网页的Javascript代码越来越庞大,越来越复杂. 网页越来越像桌面程序,需要一个团队分工协作.进度管理.单元测试等等......开发者 ...
随机推荐
- [讲解]网络流最大流dinic算法
网络流最大流算法dinic ps:本文章不适合萌新,我写这个主要是为了复习一些细节,概念介绍比较模糊,建议多刷题去理解 例题:codevs草地排水,方格取数 [抒情一下] 虽然老师说这个多半不考,但是 ...
- RecyclerView实现拖动排序和滑动删除功能
RecyclerView 的拖动排序需要借助一下 ItemTouchHelper 这个类,ItemTouchHelper 类是 Google 提供的一个支持 RecyclerView 滑动和拖动的一个 ...
- Pytest系列(4) - fixture的详细使用
如果你还想从头学起Pytest,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1690628.html 前言 前面一篇讲了setup.te ...
- Html,Css遇到的bug2020031601
td,里面jquery设置height,设置成功也没有效果. div可以成功设置,并产生效果. 可能是td,div有一些隐藏的特性不同导致的.
- jvm的类加载机制总结
类的加载机制分为如下三个阶段:加载,连接,初始化.其中连接又分为三个小阶段:验证,准备,解析. 加载阶段 将类的.class文件中的二进制数据读入到内存中,将其放在运行时数据区的方法区内,然后再堆内创 ...
- M - 湫湫系列故事——减肥记I
M - 湫湫系列故事--减肥记I 对于吃货来说,过年最幸福的事就是吃了,没有之一! 但是对于女生来说,卡路里(热量)是天敌啊! 资深美女湫湫深谙"胖来如山倒,胖去如抽丝"的道理,所 ...
- Java 连接数据库总是报错
mysql账号密码是正确的,但是一直报账号密码错误. 报错信息: java.sql.SQLException: Access denied for user 'root'@'localhost' (u ...
- RHCS概述
RHCS概述 创建RHCS集群环境 创建高可用Apache服务 1 创建RHCS集群环境 1.1 问题 准备四台KVM虚拟机,其三台作为集群节点,一台安装luci并配置iSCSI存储服务,实现如下功能 ...
- docker+nginx 微信支付回调
制作微信支付发现回调有问题: docker-compose中接口要映射对应地址 然后再进行访问
- [go]map基本使用和底层原理
1.map基本使用 map声明 var m4 map[int]int //只是声明 没有开辟空间 m4[1]=100 //报错 log.Println(m4) 创建 //1 m3:=make(map[ ...