Home > Mobile >  less than or equal to in codeigniter using mysql not working
less than or equal to in codeigniter using mysql not working

Time:10-04

i have a simple query like below:

$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 fetch the values which are more than or equal to 3 values and less than or equal to, but i dont get the result as i wanted, for example if i give value 12, i need values from 9 to 15, but it gives me some random values like till 25 and all, can anyone please tell me how to fix this

CodePudding user response:

Change code to this. You had two >= so if you had 12 then backlogs >= 9 and backlogs >= 15 so all over 9 was matching.

$this->db->where('backlogs >=', $backlogs-3);
$this->db->where('backlogs <=', $backlogs 3);
  • Related