Welcome Guest, Not a member yet? Register   Sign In
Need query help please!
#1

[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>&lt;?echo  $row->$firstname?&gt;</h3>
&lt;? endforeach;?&gt;

Now obviously the error is that i am calling result() on a non object, but how do I return the results as an object?


Messages In This Thread
Need query help please! - by El Forum - 01-31-2009, 01:44 PM
Need query help please! - by El Forum - 01-31-2009, 02:45 PM
Need query help please! - by El Forum - 01-31-2009, 02:47 PM
Need query help please! - by El Forum - 01-31-2009, 03:09 PM
Need query help please! - by El Forum - 01-31-2009, 03:10 PM
Need query help please! - by El Forum - 01-31-2009, 04:37 PM
Need query help please! - by El Forum - 01-31-2009, 04:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB