作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<分区>
我有五个输入字段,即技能、位置、公司、经验和薪水。根据用户要求,我将从数据库中获取值。我的问题是,如何动态使用 where 条件?考虑用户在技能和公司输入字段中输入值,我想从数据库中获取这些值该怎么做?现在我保留了 20 个 if 条件来解决这个问题
public function get_jobonline($skillname,$userid,$location)
{
$company=$this->input->post('searchcompany');
$experience=$this->input->post('experience');
$salary=$this->input->post('salary');
echo $company;
if($location==NULL)
{
$query=$this->db->query("SELECT j.id AS job_id, j.created_date,j.title, l.city AS location, cm.name AS company_name,
cm.logo FROM `jobs` AS j
LEFT JOIN `keyword` AS k ON `k`.`job_id` = `j`.`id`
LEFT JOIN `keyword_master` AS km ON `km`.`id` = `k`.`keyword_id`
LEFT JOIN `location_master` AS l ON `l`.`id` = `j`.`location`
LEFT JOIN `company_master` AS cm ON `cm`.`id` = `j`.`company_id`
WHERE km.name = '$skillname' AND j.uid='$userid'
;");
}
else
{
$query=$this->db->query("SELECT j.id AS job_id, j.created_date,j.title, l.city AS location, cm.name AS company_name,
cm.logo FROM `jobs` AS j
LEFT JOIN `keyword` AS k ON `k`.`job_id` = `j`.`id`
LEFT JOIN `keyword_master` AS km ON `km`.`id` = `k`.`keyword_id`
LEFT JOIN `location_master` AS l ON `l`.`id` = `j`.`location`
LEFT JOIN `company_master` AS cm ON `cm`.`id` = `j`.`company_id`
WHERE km.name = '$skillname' AND j.uid='$userid' AND l.city='$location'
;");
}
// if($company != NULL && )
return $query->result_array();
}
我是一名优秀的程序员,十分优秀!