Codeigniter form_dropdown error in form_helper at line 331 -


i'm new codeigniter , wanted create form using form_dropdown. tried lots of ideas others doesn't make right. wanted recreate online hotel reservation project using codeigniter because wamp server 2 doesn't support mysql extensions anymore , want learn more php using frameworks:

here model:

public function room_options()         {             $query = $this->db->get('room_type');              if($query->num_rows() > 0)             {                 foreach($query->result() $row)                 {                     $data[$row->room_type_id] = $row->room_type_name;                 }                 return $data;             }         }          public function check_rooms($room_type)         {              $this->db->where('room_type_id', $room_type);             $this->db->where('`room_id` not in (select `room_id` `reservation`)', null, false);             $query = $this->db->get('room');             var_dump($this->db->queries);              if($query->num_rows() > 0)             {                 foreach($query->result() $row)                 {                     $data[$row->room_id] = $row->room_name;                 }                 return $data[0];             }         } 

here controller:

public function welcome_page($page = 'welcome_page') {     if ($this->session->userdata('is_logged_in'))     {     if(! file_exists('application/views/'.$page.'.php'))     {         show_404();     }             $this->load->model('check_availability_model');             $data['options'] = $this->check_availability_model->room_options();             $this->load->view('includes/member_header');             $this->load->view('includes/member_navigation');     $this->load->view(''.$page, $data);             $this->load->view('includes/member_footer');     }     else     {     redirect('member/restricted');     } }  public function restricted() {     $this->load->view('restricted'); }  public function register($page = 'register') {     if(! file_exists('application/views/'.$page.'.php'))     {         show_404();     }     $this->load->view('includes/header');     $this->load->view(''.$page);     $this->load->view('includes/header'); }      public function check_reservation()     {         $this->load->library('form_validation');         $this->form_validation->set_rules('room_type', 'room type', 'required|trim|xss_clean|callback_reserve_credentials');         $this->form_validation->set_rules('checkin_date', 'checkin date', 'required|trim|xss_clean');         $this->form_validation->set_rules('checkout_date', 'checkout date', 'required|trim|xss_clean');          if($this->form_validation->run()==false)         {             $this->load->model('check_availability_model');             $data['options'] = $this->check_availability_model->room_options();             $this->load->view('includes/member_header');             $this->load->view('includes/member_navigation');     $this->load->view('welcome_page', $data);             $this->load->view('includes/member_footer');         }         else         {             redirect('member/reservation_form');         }     }      public function reserve_credentials()     {         $this->load->model('check_availability_model');         if($this->check_availability_model->check_rooms($this->input->post('room_type')))         {             return true;         }         else         {             $this->form_validation->set_message('reserve_credentials', 'the room not available @ time. please choose another.');             return false;         }     }  public function reservation_form($page = 'reservation_form') {     if ($this->session->userdata('is_logged_in'))     {     if(! file_exists('application/views/'.$page.'.php'))     {         show_404();     }             $this->load->library('subquery');             $this->load->model('check_availability_model');             $data['options'] = $this->check_availability_model->check_rooms($this->input->post('room_type'));             $this->load->view('includes/member_header');             $this->load->view('includes/member_navigation');     $this->load->view(''.$page, $data);             $this->load->view('includes/member_footer');     }     else     {     redirect('member/restricted');     } } 

and view:

    <?php echo form_open('member/check_reservation', array('class' => 'form col-md-12 center-block', 'role' => 'search'));?>     <?php echo form_dropdown('room_name', $options, set_value('room_name'), 'class="form-control input-lg"');?>     <p></p>     <?php echo form_submit('register_submit', 'register', "class='btn btn-primary btn-lg btn-block'");?>     <p></p>     <?php echo validation_errors();?>     <?php echo form_close();?> 

the user select room type , dates. redirected form user select again room name room type did user selected earlier. tried var_dump query , says:

0 => string 'select * (room) room_type_id = 0 , room_id not in (select room_id reservation)' (length=107)

$this->input->post('room_type') has read.

your appreciated. thank much.     [1]: http://i.stack.imgur.com/3way2.png 

  else     {         return false;     } 

you need return empty array here.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -