<input type="checkbox" class="dosage" id="table_text2<?=$i?>" name="dosage_a[]" value="Yes"/>
<input type="checkbox" class="dosage" id="table_text1<?=$i?>" name="dosage_m[]" value="Yes"/>
<input type="checkbox" class="dosage" id="table_text3<?=$i?>" name="dosage_e[]" value="Yes"/>
$dos_a = $this->input->post('dosage_a');
$dos_m = $this->input->post('dosage_m');
$dos_e = $this->input->post('dosage_e');
$OrderItemDetails[$i] = array( 'Dosage_Morning' => $dos_m[$i],'Dosage_Noon' => $dos_a[$i],'Dosage_Evening' => $dos_e[$i] );}`
答案 0 :(得分:0)
您可以尝试这样
public function did_add() {
$types = $this->input->post('dosage_m');
$data = array(
'fanta' => 0,
'cola' => 0,
'sprite' => 0,
);
foreach ($types as $type) {
$data[$type] = 1;
}
$query = $this->db->insert('table_example2', $data);
if ($query) {
return true;
}
else {
return false;
}
}
答案 1 :(得分:0)
你在控制器中有值
$dos_a = $this->input->post('dosage_a');
$dos_m = $this->input->post('dosage_m');
$dos_e = $this->input->post('dosage_e');
然后
$this->your_model->your_method($dos_a, $dos_m,$dos_e)
在模型中首先得到值
your_model($dos_a, $dos_m,$dos_e)
{
$OrderItemDetails = array(
'Dosage_Morning' => $dos_m,
'Dosage_Noon' => $dos_a,
'Dosage_Evening' => $dos_e);
$this->db->insert('your_tablename',$OrderItemDetails );
}
和bingo