<?php
    $car_option_sql ="SELECT *
                        FROM code_master mst
                        WHERE  nm_table = 'car_master'
                            AND nm_column = 'ds_car_option'
                            AND ds_delind='N'
                            order by no_order asc";
	// echo $car_option_sql;
    $car_option_res = mysql_query($car_option_sql);
?>
                <!-- <ul id="car_option_list"> -->
            <?php
                $nm_cont_detail_arr = array();
                if(!empty($nm_cont_detail)) {
                    $nm_cont_detail_arr = explode(",", $nm_cont_detail);
                }

				$option_sub_seq = 1;
                while($car_option_col = mysql_fetch_array($car_option_res)) {
                    $car_option_detail_sql ="SELECT *
                                                FROM code_master mst
                                                WHERE  nm_table = 'car_master'
                                                    AND nm_column = 'ds_car_option_detail'
                                                    AND nm_pcode = '".$car_option_col['nm_code']."'
                                                    AND ds_delind='N'
                                                    order by no_order asc ";


                    $car_option_detail_res = mysql_query($car_option_detail_sql);
            ?>
					<h2><?=$car_option_col['nm_name']?></h2>
					<ul>
					<!-- <li code="<?=$car_option_col['nm_code']?>"> -->
						<!-- <p><?=$car_option_col['nm_name']?></p> -->
            <?php

                    while($car_option_detail_col = mysql_fetch_array($car_option_detail_res)) {
                        $car_option_selected = "";
                        if(in_array($car_option_detail_col['nm_code'], $nm_cont_detail_arr)) {
                            $car_option_selected = " checked";
                        }
            ?>
						<li>
							<div class="form--group">
								<input type="checkbox" hidden id="car_option_chk<?=$option_sub_seq?>" name="nm_cont_detail[]" value="<?=$car_option_detail_col['nm_code']?>" <?=$car_option_selected?>>
								<label for="car_option_chk<?=$option_sub_seq?>"><?=$car_option_detail_col['nm_name']?></label>
							</div>
						</li>

						<!-- <label class="check_wrap"><?=$car_option_detail_col['nm_name']?>
							<input type="checkbox" name='nm_cont_detail[]' value='<?=$car_option_detail_col['nm_code']?>' <?=$car_option_selected?>><span class="checkmark"></span>
						</label> -->
                <?php
							$option_sub_seq++;
                        }
                ?>
					</ul>
                <?php
                    }
                ?>
				<!-- </ul> -->

                <?php if(!$option_insert) {?>
                <script>
                $("#car_option_list input[type=checkbox]").attr("disabled", true);
                $("#car_option_list textarea[name=nm_cont]").attr("disabled", true);
                </script>
                <?php } ?>
