朋友您好我在codeigniter下拉列表中遇到问题.... 它工作得很好,但有一个我无法解决的问题...
直接进入代码是我的* 模式 * 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;}
我的控制器
$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);
和我的观点
<tr>
<td>BATCH</td>
<td><?php echo form_dropdown('Batch',$batch); ?></td>
</tr>
产生的结果是这样的
<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>
现在的问题是我想要的值也像BCS12,BCS14,IMS01等不是0,1,2,3 ......但是值是0,1,2,3,4 ......任何1帮助我PLZ ...非常感谢提前
答案 0 :(得分:0)
将此功能更新为
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;}