Welcome Guest, Not a member yet? Register   Sign In
Calling the database from a view file?
#3

[eluser]timsby[/eluser]
Sorry but not really i'm a little more confused now, how would i develop this into a model to use on a more regular basis bearing in mind the above code is located inside a blog entries foreach loop, it gets the row id of the entry and uses it to count how many corresponding comments there relating to that row id inside the comments table.

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

<?php
    $this->db->where('entry_id', $row->id);
    $comments_num = $this->db->count_all_results('comments');
?>

<h3>&lt;?=$row->title?&gt;</h3>
<p>&lt;?=$row->body?&gt;</p>

<p>&lt;?=anchor('blog/comments/'.$row->id, 'Comments ('.$comments_num.')');?&gt;</p>

<hr>

&lt;?php endforeach; ?&gt;


Messages In This Thread
Calling the database from a view file? - by El Forum - 02-08-2009, 11:42 AM
Calling the database from a view file? - by El Forum - 02-08-2009, 12:04 PM
Calling the database from a view file? - by El Forum - 02-08-2009, 01:18 PM
Calling the database from a view file? - by El Forum - 02-08-2009, 01:54 PM
Calling the database from a view file? - by El Forum - 02-08-2009, 02:16 PM
Calling the database from a view file? - by El Forum - 02-08-2009, 02:49 PM
Calling the database from a view file? - by El Forum - 02-08-2009, 02:54 PM
Calling the database from a view file? - by El Forum - 02-10-2009, 12:36 AM
Calling the database from a view file? - by El Forum - 02-11-2009, 08:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB