Моя форма:
<ul id="hostel_facility" class="dropdown-menu dropdown-select">
<?php $facility = $conn->query("SELECT * FROM os_facilities ORDER BY id_facility ASC");
while ($facilityresult = $facility->fetch_assoc()) { ?>
<li><a><input type="checkbox" name="hostel_facility[]" value="<?php echo $facilityresult['id_facility']; ?>" /><?php echo $facilityresult['facility_name']; ?></a></li>
<?php } ?>
</ul>
Вот моя страница контроллера после сохранения задания:
$hostelId=$conn->insert_id;
if($addHostel)
{
foreach($hostelData['hostel_facility'] as $key=>$facility)
{
$conn->query("INSERT INTO os_hostel_facility (id_hostel,id_facility) values ('".$hostelId."','".$facility."')");
}