更新多个数据

时间:2013-07-08 13:12:53

标签: php database codeigniter updates

我无法解决这个问题:

$data=array(
for($i=1; $i<=$tot+1; $i++){    

array(                  

'id_jenisjadwal' => $this->input->post('jenis_jadwal'),

'bulan_tahunkp' => $bln_thn,

'id_ruang' => $this->input->post('ruang'.$i),

'tgl_sidangkp' => $this->input->post('tgl'.$i),

'jam_awalkp' => $this->input->post('awal'.$i),

'jam_akhirkp' => $this->input->post('akhir'.$i)

)
});
$this->db->update_batch('jadwal_kp',$data,'id_jenisjadwal'); 

2 个答案:

答案 0 :(得分:1)

您正在执行一个循环,其中应该存在数组的定义。

$data=array();

  for($i=1; $i<=$tot+1; $i++){  

   $data[$i] = array(                  

 'id_jenisjadwal' => $this->input->post('jenis_jadwal'),

 'bulan_tahunkp' => $bln_thn,

'id_ruang' => $this->input->post('ruang'.$i),

 'tgl_sidangkp' => $this->input->post('tgl'.$i),

'jam_awalkp' => $this->input->post('awal'.$i),

'jam_akhirkp' => $this->input->post('akhir'.$i)

 );
}

答案 1 :(得分:0)

黑暗中的野生刺伤==

$data = array();

for($i=1; $i<=$tot+1; $i++){

$data[] = array(

your data bits in the middle .......

);

}