Welcome Guest, Not a member yet? Register   Sign In
Just the first record
#2

[eluser]Michael Wales[/eluser]
I'm not exactly sure what the question is...

Your title says just the first record - to select just the first:

Code:
$query = $this->db->get('table', 1, 0);
return $query->row();

What your explanation sounds like is you are selecting titles and want to echo them out on at a time. For some reason you don't want to use foreach - not sure why, since that is what it is for...

Code:
$query = $this->db->get('table');
foreach ($query->result() as $record) {
  echo '<p>' . $record->title . '</p>';
}

Of course, this code is sloppy - there should be quite a few more checks to ensure what you expect to happen is happening, but you get the idea.


Messages In This Thread
Just the first record - by El Forum - 06-01-2008, 11:19 AM
Just the first record - by El Forum - 06-01-2008, 12:34 PM
Just the first record - by El Forum - 06-01-2008, 12:40 PM
Just the first record - by El Forum - 06-01-2008, 02:24 PM
Just the first record - by El Forum - 06-01-2008, 03:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB