我嘗試存儲複選框的值subject_id,但是當我將此值存儲到數據庫時,它只是將最後選定的複選框存儲在數據庫中...請幫助我整理代碼所以我可以得到所有選定的值。我想保存所有我選擇的複選框值
我想保存所選擇的所有複選框值,但如果我選中多個複選框,它總是保存最後一個複選框。
function get_class_section($day='',$section='',$class='')
{
print_r($section);
$sections = $this->db->get_where('class_routine' , array(
'day' => $day,'section_id'=>$section,'class_id'=>$class
))->result_array();
foreach ($sections as $row) {
echo "<table class=\"table table-bordered datatable\" id=\"table_export\" >";
echo "<thead>";
echo "<th>Subject</th><th colspan=\"2\">status</th>";
echo "</thead>";
echo "<tbody>";
echo "<tr>";
echo "<td>". $this->crud_model->get_subject_name_by_id($row['subject_id'],"<input type=\"text\" name=\"subject_id\" value=\"subject_id\" >");
echo "<input type=\"checkbox\" name=\"types[]\" value=\"".$row['subject_id']."\" set_checkbox('types[]', 'subject_id')>";
echo "</td>";
echo "<td>present <input type=\"checkbox\" value=\"1\" ></td>"
. "<td>Absent <input type=\"checkbox\" name=\"types[]\" value=\"0\"></td>";
echo "</tr>";
echo "</tbody>";
echo "</table>";
}
}
如何保存的一切,我選擇
我應該在哪裏把這個表上面? – jowy
此代碼是爲控制器,您保存數據 –
這是正確的答案 – jowy