Managing Database Information
<?php
if(isset($_POST["insert"]))
{
$conn = mysqli_connect("localhost", "root", "", "databaseappfeature");
if(isset($_POST["insert"]) == "1"){
$query = "UPDATE appfeature SET feature_switch = ('".$_POST["insert"]."')";
$result = mysqli_query($conn, $query);
echo "Data Inserted Successfully!";
}
}
?>
Javascript Functionality
<script>
$(document).ready(function(){
$('#submit').click(function(){
var insert = [];
$('.get_value').each(function(){
if($(this).is(":checked"))
{
insert.push($(this).val());
}
});
insert = insert.toString();
$.ajax({
url: "insert.php",
method: "POST",
data:{insert:insert},
success:function(data){
$('#result').html(data);
}
});
});
});
</script>
Checkbox Configuration
<form action="" method="POST">
<h4 id="result"></h4>
<div class="container">
<h2 align="center">Table App Feature</h2>
<table id="appFeature" class="table table-hover" align="center" style="width:500px;margin:auto;">
<thead>
<tr>
<th>Firstname</th>
<th>Please check to enable the features</th>
</tr>
</thead>
<tbody>
<tr>
<td>Smarthome</td>
<td>
<input type="checkbox" class="get_value" value="1" />
</td>
</tr>
<tr>
<td>Intercom</td>
<td>
<input type="checkbox" class="get_value" value="1" />
</td>
</tr>
...
<tr>
<td>Feedback</td>
<td>
<input type="checkbox" class="get_value" value="1" />
</td>
</tr>
</tbody>
</table><br />
<div align="center">
<button type="button" name="submit" id="submit">Update</button>
</div>
</div>
</form>
Looking to Update Checkbox Values in the Database? Preview of CheckboxesSee jQuery ImplementationSample Database Code Need assistance with this task? Reach out for help as I'm relatively new to this and have been working on it for a week.