Это моя форма для добавления услуг, предоставленных клиентом :
![this is my form to add the services the customer availed](https://i.stack.imgur.com/j3RN0.jpg)
Это изображение - моя таблица из базы данных :
![this image is my table from database](https://i.stack.imgur.com/GP3dG.jpg)
Вот мой PHP-код для отображения сервисов с флажками :
![here is from my PHP code to display services with the checkboxes](https://i.stack.imgur.com/CK3Yr.jpg)
Вопрос: Как я могу вставить выбранные флажки в свою таблицу базы данных.Это изображение показывает мою таблицу, где я могу сохранить выбранную базу данных
![](https://i.stack.imgur.com/oowt8.jpg)
Если я использую jQuery, как я могу применить его и вставить в свою таблицу?
Этот код взят из моего create_serviceAvailed.php
<?php include('assets/session.php'); ?>
<?php include('php/insert_serviceAvailed.php'); ?>
<!DOCTYPE html>
<html class="no-js" lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Availed Service</title>
<?php include('assets/style.php') ?>
</head>
<body>
<?php include('assets/topbar_index.php'); ?>
<div class="header">
<h2>Add Service Availed</h2>
</div>
<form method="post">
<div class="grid-container">
<div class="small-6 cell">
<label> Reciept No.
<input type="number" name="reciept_no" placeholder="Reciept No" required>
</label>
</div>
<div class="small-12 cell">
<label> Customer ID
<select name="customer_id">
<?php
$sql = "SELECT * FROM Customer";
$result = mysqli_query($db, $sql);
if(mysqli_num_rows($result)){
while($row = mysqli_fetch_array($result)){
?>
<option value="<?php echo $row['customer_id'];?>"><?php echo $row['first_name'];?></option>
<?php
}
}
?>
</select>
</label>
</div>
<div class="checkbox">
<?php $result1 = mysqli_query($db, "SELECT * FROM Services");
while ($row1 = mysqli_fetch_array($result1)) {?>
<input type="checkbox" class="get_value" name="<?php echo $data[$count] ?>" value="<?php echo $ServiceID; ?>" ><?php echo $row1['Serv_Name']; ?>
<?php
}?>
</div>
</div>
<button class="button expanded" type="submit" name="submit" id="submit">Save</button>
</form>
<!-- Scripts -->
<script src="Foundation/js/vendor/jquery.js"></script>
<script src="Foundation/js/vendor/what-input.js"></script>
<script src="Foundation/js/vendor/foundation.js"></script>
<script src="Foundation/js/app.js"></script>
</body>
</html>
Этот код взят из insert_serviceAvailed.php
<?php
$user_id = $_SESSION['username'];
// connect to the database
$db = mysqli_connect('localhost', 'root', '', 'beautysalon');
//check connection
if($db === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// adding contact
if (isset($_POST['submit'])) {
// receive all input values from the form
$reciept_no = $_POST['reciept_no'];
$customer_id = $_POST['customer_id'];
$Services_checked = $_POST['Services_checked'];
$sql = "INSERT INTO `Services_availed` (`reciept_no`, `customer_id`, `Services_checked`, `timestamp`) VALUES ('$reciept_no', '$customer_id', '$Services_checked', CURRENT_TIMESTAMP);";
$result = mysqli_query($db, $sql);
if($result == true){
header('Location:service_availed.php');
}else{
echo "Something went wrong";
}
}