我想和Codeigniter制作一个时间表 但我遇到循环问题。
我的观点
类
`<input type="checkbox" name="class[]" value="1A" id="1a" /> 1A
<input type="checkbox" name="class[]" value="1B" id="1b" /> 1B
<input type="checkbox" name="class[]" value="1C" id="1c" /> 1C `
小时
<input type="checkbox" name="hours[]" value="1" id="h1" /> hours 1
<input type="checkbox" name="hours[]" value="2" id="h2" /> hours 2
<input type="checkbox" name="hours[]" value="3" id="h3" /> hours 3
<input type="checkbox" name="hours[]" value="4" id="h4" /> hours 4
<input type="checkbox" name="hours[]" value="5" id="h5" /> hours 5
<input type="checkbox" name="hours[]" value="6" id="h6" /> hours 6
天
`<input type="checkbox" name="day[]" value="1" id="Monday" /> Monday
<input type="checkbox" name="day[]" value="2" id="Tuesday" /> Tuesday
<input type="checkbox" name="day[]" value="3" id="Wednesday" /> Wednesday
<input type="checkbox" name="day[]" value="4" id="Thursday" /> Thursday
<input type="checkbox" name="day[]" value="5" id="Friday" /> Friday
<input type="checkbox" name="day[]" value="6" id="Saturday" /> Saturday `
室
`A
<input type="checkbox" name="room[]" value="B" id="b" /> B
<input type="checkbox" name="room[]" value="C" id="c" /> C
<input type="checkbox" name="room[]" value="C" id="d" /> D `
我的模特
function add(){
$day= $this->input->post('day');
$hours= $this->input->post('hours');
$class= $this->input->post('class');
$room= $this->input->post('room');
foreach ($hoursas $hr){
$data = array('day'=>$day,'hours'=>$hr,'class'=>$class,'room'=>$room);
$this->db->insert('t_jadual', $data);
}
}
如何循环$ class,$ room和$ day?