Are you a regular stikked user? Signup so you can keep track of your pastes!
  1. <?php
  2. class Blog extends Controller {
  3.        
  4.         function blogs()
  5.         {
  6.                 $this->load->model('blog_model');
  7.                 $data['blogs'] = $this->blog_model->get_blogs();
  8.                 $this->load->view('blog_view', $data);
  9.         }
  10. }
  11. ?>
  12.  
  13.  
  14. <?php
  15. class Blog_model extends Model {
  16.        
  17.         function Blog_model() {
  18.                 parent::Model();
  19.         }
  20.  
  21.         function get_blogs() {
  22.                 $query = $this->db->get('blogs');
  23.                 return $query->result();
  24.         }
  25.  
  26. }
  27. ?>
  28.  
  29. <html>
  30. <head>
  31. <title>My Blog Page</title>
  32. </head>
  33. <body>
  34. <h3>My Blogs</h3>
  35. <ul>
  36. <?php foreach($blogs as $blog):?>
  37. <h4><?=$blog['title']?></h4>
  38. <p><?=$blog['body']?></p>
  39. <p>Posted by <?=$blog['author']?></p>
  40. <?php endforeach;?>
  41. </ul>
  42. </body>
  43. </html>

Reply to "Untitled"

Here you can reply to the paste above

Create a snipurl

Make Private

Feeling clever? Set some advanced options.