Issue
This Content is from Stack Overflow. Question asked by enforeach zero
I Tried of making sort of names using Codeigniter but I found a problem, Please help me
Here is my data
- Doe Blablabla
- blablalba doe blablabla
- blablabla doe
- doe
I wanna sort it becomes like below but with some limit
- doe
- doe blablabla
- blablabla doe blablala
- blablabla doe
And here’s my code, but the sort won’t work yet
public function getFilter($name)
{
$this->db->select("*, (CASE people
WHEN people = '$name' THEN 1
WHEN people LIKE '$name%' THEN 2
ELSE 3
END) as people_name");
$this->db->from('citizen');
$this->db->like('people', $id);
$this->db->order_by("people_name asc");
$this->db->limit(2);
return $this->db->get()->result();
}
Solution
This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.
This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.