If you are finding way to how to get random records from mysql table in codeigniter project then you are a right place. You can easily get random rows using codeigniter query builder order_by. here you will see the example of getting random result using order_by in codeigniter 3.
In order_by(), we have to pass two argument parameter, one is a column name and another is a ‘RANDOM’ then codeigniter query builder class will return random value every time from mysql database table. So just check bellow example:
$this->db->order_by('id','RANDOM'); $data = $this->db->get("items");
$this->db->order_by(42,'RANDOM'); $data = $this->db->get("items");
You can check now.
I hope you found your solution…