<?php
include $_SERVER['DOCUMENT_ROOT'] . '/classes/autoload.php';

$question_name = $_POST['name'];
$question_id = $db->query("job_card_additional_details", "INSERT INTO job_card_additional_details (`question`,`user_id`) VALUES ('$question_name','" . $_SESSION['user_id'] . "')");
if ($question_id > 0) {
    $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 ('$question_id','$option','" . $_SESSION['user_id'] . "')");
    }
}