Here are the code.
<!DOCTYPE html>
<html lang="en">
<body>
<div class="content">
<div class="container-fluid page-body-wrapper">
<div class="main-panel">
<div class="content-wrapper">
<div class="row">
<div class="col-md-12 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<h3>Attendance of <?php echo date('Y-m-d'); ?></h3>
<br>
<form action="" method="post" class="form-horizontal col-md-6 col-md-offset-3">
<div class="form-group">
<strong>Select Month</strong>
<?php
// Check if the month is set in $_POST
$selectedMonth = isset($_POST['whichmonth']) ? $_POST['whichmonth'] : '';
?>
<input id="inputmonth" type="month" name="whichmonth" required="true" class="form-control" value="<?php echo $selectedMonth; ?>">
</div>
<div class="col-xs-6">
<button type="submit" class="btn btn-danger col-md-2 col-md-offset-5" style="border-radius:0%" name="search">Search</button>
<input type="submit" class="btn btn-primary col-md-2 col-md-offset-10" value="Save!" name="save" />
</div>
<table class="table table-stripped">
<thead>
<tr>
<th scope="col">Id. No.</th>
<th scope="col">Name</th>
<th scope="col">Designation</th>
<th scope="col">Salary</th>
<th scope="col">Present</th>
<th scope="col">PSalary</th>
</tr>
</thead>
<tbody>
<?php
// if (isset($_POST['search'])) {
$con = mysqli_connect("localhost", "root", "", "madrasadb");
// Prepare the SELECT statement
$all_query = mysqli_prepare($con, "SELECT id, name, designation, salary FROM jack ORDER BY id ASC");
// Execute the prepared statement
mysqli_stmt_execute($all_query);
// Bind the result variables
mysqli_stmt_bind_result($all_query, $id, $name, $designation, $salary);
while (mysqli_stmt_fetch($all_query)) {
?>
<tr>
<td><?php echo $id; ?> <input type="hidden" name="stat_id[]" value="<?php echo $id; ?>"></td>
<td><?php echo $name; ?><input type="hidden" name="stat_name[]" value="<?php echo $name; ?>"></td>
<td><?php echo $designation; ?> <input type="hidden" name="stat_fname[]" value="<?php echo $designation; ?>"></td>
<td><?php echo $salary; ?> <input type="hidden" name="salary[]" value="<?php echo $salary; ?>"></td>
<td>
<input type="number" name="st_status[]" style="width:70px" max="31" value="<?php echo isset($_POST['whichmonth']) ? date('t', strtotime($_POST['whichmonth'])) : ''; ?>" onchange="calculateTotalSalary(this, <?php echo $id; ?>)">
</td>
<td>
<input type="number" id="totalSalary<?php echo $id; ?>" name="total_salary[]" style="width:70px" readonly>
</td>
</tr>
<?php
}
mysqli_stmt_close($all_query);
mysqli_close($con);
?>
</tbody>
</table>
</form> …