我正在PHP CI中过滤数据库中的数据,我需要使用dd菜单过滤具有固定数据的数据(本月、本季度、本年(。这是下拉的代码
<select class="form-control lb-sort leaderboard-select" name="filter">
<option >Sort</option>
<option value="MONTH">This Month</option>
<option value="QUARTER">This Quarter</option>
<option value="YEAR">This Year</option>
<option>All Time</option>
</select>
这里是我用来过滤数据的查询代码
$filter = "";
$filter_leaderboard="";
if($_GET['filter']){
$filter = $_GET['filter'];
}
if($filter === "MONTH"){
$filter_leaderboard = "MONTH(updated_date) = MONTH(NOW())";
}else if($filter === "QUARTER"){
$filter_leaderboard = "QUARTER(updated_date) = QUARTER(NOW())";
}else if($filter === "YEAR"){
$filter_leaderboard = "YEAR(updated_date) = YEAR(NOW())";
}
$paramSelect = "*";
$paramTable = " tbl_user where ".$filter_leaderboard ;
$data['user'] = $this->Common_model->Common_join($paramSelect,$paramTable);
但是过滤不起作用?
你能帮我查一下哪里是我的错吗?
将$filter_leaderboard=""
替换为$filter_leaderboard=null
,然后重试。