Less than or equal to using mysql in codeigniter does not work
P粉445714413
P粉445714413 2024-03-22 08:57:14
0
1
325

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

P粉445714413
P粉445714413

reply all(1)
P粉055726146

Change the code to this. You have two >=, so if you have 12, backlog >= 9 and backlog >= 15, so all 9+ are matched.

$this->db->where('backlogs >=', $backlogs-3);
$this->db->where('backlogs 
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template