代码点火器多个where子句不起作用

Code igniter model returns json_encode results when page load gender=3, if click female button gender=1 and if click male button gender=2. Now i want to add another where statements in side the if conditions. see when gender=3 if condition.

function get_data_all($gender, $age_min, $age_max) { 
        
        $counter = 0;             
        $this->db->select('*');             
        if($gender == 1){ 
            $this->db->where('gender', 'F'); //working 
            $counter++;
        }
        elseif($gender == 2){
            $this->db->where('gender', 'M');  //working                        
            $counter++;
        }
        elseif($gender == 3){                   
            $names = array('F', 'M');              
            $this->db->where_in('gender', $names);   //working 
            $this->db->where('age>=', 12);  //not working
            $this->db->where('age<=', 18);  //not working               
            $counter++;
        }
        else{
            redirect(base_url());
        }                    
        $query = $this->db->get('sudent_details');               
        if (($query->num_rows() > 0) && ($counter > 0)){                
            echo(json_encode($query->result()));                          
            $counter = 0;                            
        } else {                
            return false;
        }
    }

</div>

Add space in your column name & Comparison operator

$this->db->where('age >= ', 12);
$this->db->where('age <= ', 18);

You need to replace following lines:

$this->db->where('age>=', 12);  //not working
$this->db->where('age<=', 18);  //not working  

TO:

$this->db->where('age','>=',12);  
$this->db->where('age','<=',18);

OR:

$this->db->where('age >= 12',FASLE,FALSE);  
$this->db->where('age <= 18',FASLE,FALSE);

OR:

$this->db->where('age>=', 12,FALSE);
$this->db->where('age<=', 18,FALSE);

It should work.