I have a page where there are check boxes getting loaded dynamicaly so i dont know the number of check boxes (maximum of 50) and out of those check boxes users can select any number between 1 to 50 of checkboxes and can submit the form and on the action page i need get the values of all the checkboxes and insert them to database after checking for unoqueness like this
FIRST PAGE (FORM)
<?php while($the_DEATA_ARE_90=mysqli_fetch_array($getDOCS_30all)){ ?>
<div class="This_LISy_Lisy678" id="MAINDIV_DELEE<?=$the_DEATA_ARE_90['dcid']?>">
<div class="CHeck_IS_BOC">
<input type="checkbox" name="selecteddocx[]" value="<?=$the_DEATA_ARE_90['dcid']?>x<?=$the_DEATA_ARE_90['name']?>" id="check_docname<?=$the_DEATA_ARE_90['dcid']?>"/>
on the action page i am having this code
$selecteddocx = (isset($_POST['selecteddocx']) ? $_POST['selecteddocx'] : '');
$doocx = array();
$docxid = array();
foreach($_POST['selecteddocx'] as $value){
$str = explode("x",$value,2);
$doocx[] = $str[0];
$docxid[] = $str[1];
echo=implode(",", $doocx); // i need to print this for some reasons
echo implode(", ", $docxid); // i need to print this for some reasons
i am having this query to insert the coma sepertaed vales into database i am converting the values of checkboxes into coma seperated values
$shaeredata=mysqli_query($conn,"insert into docs (dcid,pid) values ('$dcid','$pid')");
i i know i can insert the values into database in one shot like
$shaeredata=mysqli_query($conn,"insert into docs (dcid,pid) values ('$dcid','$pid'),('$dcid2','$pid'),('$dcid3','$pid'),('$dcid4','$pid')");
but i dont know how to do this as i am having the values in coma seperated (please note pid is same)
if checking of dcid can be done per pid then it will be great what i mean is thet insert only is dcid is not shared with pid (dcid already exists for that pid)