Hello friends i am having a problem with codeigniter drop down list.... it is working finely but there is a problem which i m unable to solve...
coming direct to code here is my *mode*l ..
function getBatchId(){
$batchId = $this->db->get('batch');
$batchList = array();
if($batchId->num_rows() >0){
foreach ($batchId->result_array() as $tablerow) {
$batchList[] = $tablerow['code'];
}
return $batchList;
}else {return false;}
my controller
$this->load->model('AdmissonModel');
$content = array(
'progid' => $this->AdmissonModel->getProgrameCode(),
'batch' => $this->AdmissonModel->getBatchId(),
'depid' => $this->AdmissonModel->getDepId()
);
$this->load->view('Admissions/admForm_view',$content);
and my view
<tr>
<td>BATCH</td>
<td><?php echo form_dropdown('Batch',$batch); ?></td>
</tr>
the result produced is like this
<select name="Batch">
<option value="0">BCS12</option>
<option value="1">BCS14</option>
<option value="2">IMS01</option>
<option value="3">INU01</option>
<option value="4">INU02</option>
<option value="5">INU03</option>
</select>
now the problem is that i want the values also like BCS12,BCS14,IMS01 etc not 0,1,2,3...but the values are 0,1,2,3,4.....can any 1 help me plz...thanks alot in advance
in your model update this function to
function getBatchId(){
$batchId = $this->db->get('batch');
$batchList = array();
if($batchId->num_rows() >0){
foreach ($batchId->result_array() as $tablerow) {
$batchList[$tablerow['code']] = $tablerow['code'];
}
return $batchList;
}else {return false;}