Welcome Guest, Not a member yet? Register   Sign In
Reading database data in a view
#1

[eluser]Tanag[/eluser]
Really simple question here. I'm making a call to my database that grabs a single record based on a user ID. I can't seem to read that record on my view without using a loop though. Im sure I just don't have the really simple syntax right, but I can't get it.

Here is my controller code:

Code:
$this->db->where('user_id', $data['users']);
$data['query'] = $this->db->get('users');
$this->load->view('welcome_view', $data);

That works fine, and I can view the data if I do this:

Code:
<?php foreach($query->result() as $row): ?>

<p>&lt;?=$row->user_id?&gt;</p>
<p>&lt;?=$row->class?&gt;</p>

&lt;?php endforeach; ?&gt;

But using a loop seems pointless. I know there will always be one record as the user_id is my unique field.
So how can I read the data like $query->result() as $row does. Like I want something like $query->user_id.

Any help would be great, thanks. Im sure its a simple solution and I am a dummy.


Messages In This Thread
Reading database data in a view - by El Forum - 03-13-2010, 01:49 AM
Reading database data in a view - by El Forum - 03-13-2010, 03:14 AM
Reading database data in a view - by El Forum - 03-13-2010, 03:18 AM
Reading database data in a view - by El Forum - 03-13-2010, 09:41 AM
Reading database data in a view - by El Forum - 03-13-2010, 03:10 PM
Reading database data in a view - by El Forum - 03-13-2010, 03:41 PM
Reading database data in a view - by El Forum - 03-13-2010, 07:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB