Hi I am trying to create a dropdown using a CI forms. I have a table reseller and in that i have a field called Key. Now I have another table Users where i store user's information. I want to create a new user and in that user creation form i have a drop down field called Key where i want to fetch the key of all the resellers. So that i can identify which user is mapped to which reseller using that key.
For Controller I have done this :
$data = $this->user_m->array_from_post(array('sip_id','sip_pass','name','key','email', 'password','phone','status','created','balance')); $this->load->model('reseller_m'); $this->data['resellers'] = $this->reseller_m->get('key'); $data['password'] = $this->user_m->hash($data['password']); $key=$this->user_m->save($data, $id); redirect('admin/user'); } $this->data['subview'] = 'admin/user/add'; $this->load->view('admin/_layout_main', $this->data); The View is
<tr> <td>Key</td> <?php if(count($resellers)): foreach($resellers as $reseller) ?> <td><?php echo form_dropdown('key', set_value('key', $user->key));?></td> </tr> But i dont get anything on screen. So How to create this drop-down?
:afterif(count($resellers))a typo or intentional?(condition)?true : falsewhich you are not using in your method that you have posted. So remove the:and check out.