Using Codeigntier 3
I am trying to limit my database content to 5 posts. Right now I have my foreach working correct, but I do not know how to limit the number to 5.
Most of the stuff I found online is from codeigniter 2.
Controller
public function index(){
$data['Sideposts'] = $this->Blog_Model->get_bposts();
Model
public function get_bposts($slug = FALSE){
if($slug === FALSE){
$this->db->order_by('date','DESC');
$query = $this->db->get('blogposts');
return $query->result_array();
}
View Code
<?php foreach($Sideposts as $Sidepost):{ ?>
<ul style="list-none;">
<?php echo $Sidepost['title']; ?>
</ul>
<?php }endforeach; ?>