I have a table called topics and in that there is field called vTopicName. I want to display random topics by clicking on the button without repeating them what should be the SQL query for it??
In controller I call
public function browse() { $data['topic'] = $this->topics_model->get_random_topic(); $topic = $data['topic']['vTopicName']; redirect("/$topic"); } In the model there is
public function get_random_topic() { $query = $this->db->query("SELECT * FROM ws_topics ORDER BY RAND() LIMIT 1"); return $query->row_array(); } THis will redirect to domainname.com/topicname