<?php
include $_SERVER['DOCUMENT_ROOT'] . '/classes/autoload.php';
var_dump($_POST);
$question_name = $_POST['name'];
$db->query("job_card_additional_details", "UPDATE job_card_additional_details SET `question`='$question_name',`user_id`='" . $_SESSION['user_id'] . "' WHERE record_id = {$_POST['record_id']}");
$db->query("job_card_additional_detail_options", "DELETE FROM job_card_additional_detail_options WHERE job_card_additional_detail_id = {$_POST['record_id']}");

$options = $_POST['option'];
foreach ($options as $option) {
    $option_id = $db->query(
        "job_card_additional_detail_options",
        "INSERT INTO job_card_additional_detail_options 
         (`job_card_additional_detail_id`,`option`,`user_id`) 
         VALUES ('{$_POST['record_id']}','$option','" . $_SESSION['user_id'] . "')"
    );
}