<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] );}`
Вы можете попробовать вот так
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;
}
}
у вас есть значения в контроллере
$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 );
}
и бинго