获取多个复选框并插入到Sql Database中

I know I am annoying but your help will definitely make me a good developer one day so please please help me as you help in the previous questions so my today question is I am able to learn multiple checkboxes inserted in SQL database this is my HTML code

 <form action="" method="post">

<input type="checkbox" name="check_list[]" value="C/C++"><label>C/C++</label><br/>
<input type="checkbox" name="check_list[]" value="Java"><label>Java</label><br/>
<input type="checkbox" name="check_list[]" value="PHP"><label>PHP</label><br/>
<input type="submit" name="submit" value="Submit"/>
</form>

and this works perfectly with this is PHP code

<?php
if(isset($_POST['check_list'])){
  if (is_array($_POST['check_list'])) {
    foreach($_POST['check_list'] as $selected){
     $q=mysqli_query($dbc,"INSERT INTO students (attendance) VALUES ('".$selected."')");
    }
  } else {
      echo "nothing checked";
  }
}
?>

my problem is when is insert checkboxes the value of each checkbox inserted against each id I want to insert all values against one id so basically when someone selects all boxes the values inserted against one id

Please use implode() function to convert value from array to string.

Please try below solution.

<?php
if(isset($_POST['check_list'])){
  $selected = implode(",", $_POST['check_list']);
  $q=mysqli_query($dbc,"INSERT INTO students (attendance) VALUES ('".$selected."')");
}
?>

Hope this help.