aries_

dropdown_CI

Jun 3rd, 2012
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. <------------------model----------------->
  2.   Class Train_model extends CI_Model{
  3.         function __construct()
  4.         {
  5.             parent::__construct();
  6.             $this->load->database();
  7.         }
  8.  
  9.       function Get_stream (){
  10.         $q= $this->db->get('stream');
  11.         if($q->num_rows() > 0 ){
  12.              foreach ($q->result() as $row)
  13.                 {
  14.          $data[]=$row;
  15.              }
  16.              return $data;
  17.       }
  18.         }
  19.    }
  20. <------------------>
  21.  
  22. <----------------------- Controler--------------->
  23.  class combo extends CI_Controller{
  24.  
  25.         public function  __construct() {
  26.             parent::__construct();
  27.             $this->load->model('Train_model');
  28.     }
  29.    
  30.     public function index(){
  31.      $data['stream']= $this->Train_model->Get_stream();
  32.      $this->load->view('form_input',$data);
  33.     }
  34.     }
  35. <------------------->
  36. <---------view-------------->
  37. <html>
  38.     <head>
  39.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  40.         <title></title>
  41.     </head>
  42.     <body>
  43.         <?php echo form_open('stream/input'); ?>
  44.      
  45.        <?php foreach($stream as $r) {
  46.         echo "Stream"        .' : '.form_dropdown('tes',$r);
  47.        }
  48.      
  49.         ?><br>
  50.        
  51.    
  52.     </body>
  53. </html>
  54.  
  55. <--------------->
Advertisement
Add Comment
Please, Sign In to add comment