I have a simple query that looks like this:
$backlogs=$_POST['backlogs']; $this->db->select('*'); if(!empty($backlogs)) { $this->db->where('backlogs >=', $backlogs-3); $this->db->where('backlogs >=', $backlogs+3); } $query = $this->db->get('universities');
I want the query to get values greater than or equal to 3 values and less than or equal to but I am not getting the results I want, for example if I give the value 12 I need the values in 9 to 15 but it I was given some random values like up to 25 etc, can anyone tell me how to solve this problem
Change the code to this. You have two >=, so if you have 12, backlog >= 9 and backlog >= 15, so all 9+ are matched.