$this->db->select('name'); $query = $this->db->get('table'); $shuffled_query = $query->result_array(); shuffle ($shuffled_query); foreach ($shuffled_query as $row) { echo $row['name'] . '<br />'; }