Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function comments($page){
- $this->load->library('pagination');
- $this->load->model("model_get");
- $config['base_url'] = base_url('main/comments/'.$this->uri->segment(3).'/');
- $config['total_rows'] = $this->model_get->getCommentcount();
- $config['per_page'] = 5;
- $config['uri_segment'] = 4;
- $this->pagination->initialize($config);
- $data["results"] = $this->model_get->getComments($config['per_page'], $page);
- $this->load->view('content_comment', $data);
- }
- function getComments($limit, $start){
- $this->db->from('comments');
- $this->db->where('blog_id', $this->uri->segment(3));
- $this->db->limit($limit, $this->uri->segment(4));
- $results = $this->db->get();
- if ($results)
- {
- return $results->result();
- }else{
- return FALSE;
- }
- }
- <?php
- foreach($results as $row){
- $text = $row->text;
- echo "<h3>". $text ."</h3>";
- $author = $row->author;
- echo "<p>". $author ."</p>";
- }
- $this->db->order_by("blog_id", "desc");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement