[eluser]draconus[/eluser]
I am trying to create a practitioner search page, and I am having issues with the outputting the data from the table.
Here is my model code:
Code:
function findPractitioner(){
$form = array(
'name' => $this->input->post('name'),
'city' => $this->input->post('city'),
'state' => $this->input->post('state'),
'country' => $this->input->post('country')
);
$sql = "SELECT * FROM users WHERE practitioner = 1
AND city = '$form[city]' AND state = '$form[state]' AND country = '$form[country]' AND firstName like
'%$form[name]%' or lastName like '%$form[name]%'";
$query = $this->db->query($sql);
return ($query->num_rows() > 0) ? $query->row_array() : FALSE;
}
and my controller code:
Code:
$this->load->model('users');
$data['query'] = $this->users->findPractitioner();
$this->load->view('practitioners', $data);
and my view code:
Code:
<? foreach($query->result() as $row): ?>
<h3><?echo $row->$firstname?></h3>
<? endforeach;?>
Now obviously the error is that i am calling result() on a non object, but how do I return the results as an object?