I have multiple check box with the same input name like this
[Just refer the attach image][1]`
<script>
$(document).ready(function(){
$('#student_data').DataTable();
});
</script>
<script>
$(document).ready(function() {
$("#form1 #select-all").click(function(){
$("#form1 input[type='checkbox']").prop('checked',this.checked);
});
});
</script>
<?php
/*$connect = mysqli_connect("localhost", "root", "", "doubts");
$query ="SELECT * FROM doubtsexample";
$result = mysqli_query($connect, $query); */
include 'db.php';
if (isset($_POST['submit'])){
foreach($_POST['check'] AS $value){
$stmt=$db->prepare("UPDATE");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Proper Learning</title>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script>
<script href="https://cdn.datatables.net/1.10.23/css/jquery.dataTables.min.css"> </script>
<script href="https://cdn.datatables.net/select/1.3.1/css/select.dataTables.min.css"> </script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<form id="form1" method="POST" action="physics_list.php">
<br /><br />
<div class="container">
<h3 align="center">ProperLearning Doubt Section</h3>
<br />
<div class="table-responsive">
<?php
$conn = NEW MySQLi ('localhost', 'root', '', 'doubts');
$query= "SELECT * from doubtsexample ORDER BY id desc";
$data = mysqli_query($conn, $query);
$total = mysqli_num_rows($data);
if($total != 0)
{
?>
<table id="student_data" class="table table-striped table-bordered">
<thead>
<tr>
<th><input type="checkbox" id="select-all"></th>
<th><b>ID</b></th>
<th><b>Name</b></th>
<th><b>Subject</b></th>
<th><b>Image Name</b></th>
<th><b>Image</b></th>
<th><b>Question</b></th>
<th><b>Time & Date</b></th>
<?php
$mysqli = NEW MySQLi ('localhost', 'root', '', 'doubts');
$resultSet= $mysqli->query("SELECT name FROM teacher ORDER BY id desc");
?>
<select name="teacher" id="teacher" style="margin:0px; width:276px; height:30px;" required>
<option value="">Select Teacher</option>
<?php
while($rows = $resultSet->fetch_assoc())
{
$name = $rows['name'];
echo "<option value='$name'>$name</option>";
}
?>
</select> <button type="submit" class="btn" name="submit">Submit</button> <br><br>
</tr>
</thead>
<?php
while($result = mysqli_fetch_assoc($data))
{
echo "<tr>
<td><input type='checkbox' name=check[]></td>
<td>".$result['id']."</td>
<td>".$result['username']."</td>
<td>".$result['subject']."</td>
<td>".$result['image']."</td>
<td><img src= '".$result['image']."' height='100' width='100'/></td>
<td>".$result['question']."</td>
<td>".$result['ask_at']."</td>
</tr>";
}
}
?>
</table>
</div>
</div>
</form>
</body>
</html>
question from:
https://stackoverflow.com/questions/65868902/save-the-selected-rows-by-checkbox-and-save-it-in-database-in-php 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…