I want to Insert SELECT ALL values or SELECTED values into different columns in MySQL. On choosing SELECT ALL, all the values are inserting correctly in sql but on selecting some checkboxes data is not inserting in SQL data.
Jquery
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#select_all").change(function(){
var status = this.checked;
$('.checkbox').each(function(){
this.checked = status;
});
});
$('.checkbox').change(function(){
if(this.checked == false){
$("#select_all")[0].checked = false;
}
if ($('.checkbox:checked').length == $('.checkbox').length ){
$("#select_all")[0].checked = true;
}
});
});
</script>
PHP
<?php
$addbook=$_POST['addbook'];
$memdet=$_POST['memdet'];
$vbookd=$_POST['vbookd'];
$modify=$_POST['modify'];
$result=mysqli_query($db,"insert into apanel(addbook,memdet,vbookd,modify)values('$addbook','$memdet','$vbookd','$modify')");
?>
HTML
<input type="checkbox" id="select_all"/> Selecct All<br>
<input class="checkbox" type="checkbox" value="1" name="addbook" />Add Book<br>
<input class="checkbox" type="checkbox" value="1" name="memdet" />View Member Details<br>
<input class="checkbox" type="checkbox" value="1" name="vbookd" />View Book Details<br>
<input class="checkbox" type="checkbox" value="1" name="modify" />Edit/Delete<br>
I want to insert selective checkboxes also in MYSQL database. Help required
Aucun commentaire:
Enregistrer un commentaire