I have a query that goes like this:
function getnames(){
$sql = "select * from names where status = '1'";
$query = $this->db->query($sql);
if($query->num_rows()>0){
return $query->result();
}
else{
return null;
}
}
This function is already loaded in the new_model.php. I am using CodeIgniter.
Then in the controller, I use a function that returns the query result. I already have this in the controller:
function getnames(){
return $this->new_model->getnames();
}
What I want to do is that instead of using foreach() loop in getting the array result, I want to use something else that will let me use an index number. How can I do this? Please help. Thanks!