0

你好朋友我遇到了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 都可以帮助我请...提前非常感谢

4

1 回答 1

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;}
于 2014-02-26T10:31:51.110 回答