php - Issue with storing values of Multiselect in database -


alright have hell of problem right .

i have bootstrap multiselect below allows me add or remove groups user.

enter image description here

well works there bug remove me 1 additional group each time click on "submit"

example : if user in 3 groups( blabla, bleble , blibli) , press submit without touching groups, remove user 1 group , have 2 left (blabla , bleble).

here php code used treatement :

$groupes = $_get['groupes']; $idc = $_get['idc']; if ($groupes != "null") {     $g = explode(',', $groupes);     ($i = 0; $i < count($g); $i++) {          $sqldel = "delete appartenir  idc = $idc";          $reqdel = mysqli_query($mysqli, $sqldel) or die('erreur sql !<br/>' . $sqldel . '<br/>' . mysqli_error($mysqli));     }      ($i = 0; $i < count($g); $i++) {         $sql1 = "insert appartenir(idc,idg) values('$idc', '$g[$i]')";         $req1 = mysqli_query($mysqli, $sql1) or die('erreur sql !<br/>' . $sql1 . '<br/>' . mysqli_error($mysqli));     }  } 

and htmlcode of select if helps :

 <select id="filtremultiselectmodif" name="groupes[]" multiple="multiple">                <?php              while ($data3 = mysqli_fetch_array($req3)) { // remplissage du select                 $idg = $data3['idg'];                 $intitule = $data3['intitule'];                 ?>                 <option value="<?php echo $idg ?>" selected><?php echo $intitule ?></option>             <?php } ?>             <?php               while ($data2 = mysqli_fetch_array($req2)) { // remplissage du select                 $idg = $data2['idg'];                 $intitule = $data2['intitule'];                 ?>                 <option value="<?php echo $idg ?>"><?php echo $intitule ?></option>             <?php } ?>          </select> 

i don't think putting jquery code useful

any appreciated !


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -