Advertisement
Guest User

Untitled

a guest
Dec 8th, 2011
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.58 KB | None | 0 0
  1. <?php
  2. class Main extends CI_Controller    {
  3.    
  4.     public function index() {
  5.         $query = $this->db->query("SELECT * FROM `content` WHERE `accepted`='1'");
  6.         $data[] = "";
  7.        
  8.         $config['base_url'] = base_url().'index.php/main/index/';
  9.         $config['total_rows'] = $query->num_rows();
  10.         $config['per_page'] = '10';
  11.         var_dump($this->get_cont($config['per_page'], $this->uri->segment(3)));
  12.            
  13.         //  $data['cont'] =
  14.         $this->pagination->initialize($config);
  15.         $data['links'] = $this->pagination->create_links();
  16.         $this->load->view('main', $data);
  17.     }
  18.        
  19.     function get_cont($limit = NULL, $offset = NULL, $cont = NULL)  {
  20.         $this->db->limit($limit, $offset);
  21.         $query = $this->db->get('content');
  22.        
  23.         foreach($query->result_array() as $row) {
  24.             switch ($row['type']) {
  25.                 case 'image':
  26.                     $cont[] = '<img src="/images/'.$row['value'].'" style="max-width:853px;">';
  27.                     break;
  28.                 case 'youtube':
  29.                     $cont[] = '
  30.                     <object width="853" height="480">
  31.                     <param name="movie" value="http://www.youtube.com/v/'.$row['value'].'?version=3&amp;hl=nb_NO"></param>
  32.                     <param name="allowFullScreen" value="true"></param>
  33.                     <param name="allowscriptaccess" value="always"></param>
  34.                     <embed src="http://www.youtube.com/v/'.$row['value'].'?version=3&amp;hl=nb_NO" type="application/x-shockwave-flash" width="853" height="480" allowscriptaccess="always" allowfullscreen="true"></embed>
  35.                     </object>';
  36.                     break;
  37.                 case 'text':
  38.                     $cont[] = '<h2>'.$row['value'].'</h2>';
  39.                     break;
  40.                 default:
  41.                     $cont[] = "Something went wrong.";
  42.             }
  43.            
  44.             return $cont;
  45.         }      
  46.        
  47.  
  48.  
  49.     }
  50. }
  51. ?>
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement