Iam making a daily report system. its just a hobby project. question is that how can i submit form that is displayed in while loop to sql query. as the form is in while loop, i cannot determine that how many rows are going to be inserted. so i cannot add multiple insert statements. i am thinking of showinginsert into statement in while loop also. can i do it somehow? there is some of the code to understand: Attendance.php: `
<form action="create.php" method="POST">
<?php
$query="SELECT * FROM users where class "; // SQL query to fetch all table data
$view_users= mysqli_query($conn,$query); // sending the query to the database
// displaying all the data retrieved from the database using while loop
while($row= mysqli_fetch_assoc($view_users)){
$id = $row['id'];
$marksnamaz = $row['marksnamaz'];
$class = $row['class'];
echo "<tr >";
echo " <th scope='row' >{$id}</th>";
echo " <td >{$marksnamaz}<input name='name' type='hidden' value='{$marksnamaz}'></td>";
echo "<td><select name='att'><option value='Hazir'>Hazir</option><option value='gherhazir'>Gher Hazir</option><option value='rukhsat'>Rukhsat</option></select></td>";
echo "<td><input type='text' name='reason'></td>";
echo "<td>{$class}</td>";
echo "</tr>";
}
?>
<input type="submit" name="create">
</form>
` The Create.php
`
<?php
if(isset($_POST['create']))
{
$name = $_POST['name'];
$att = $_POST['att'];
$reason = $_POST['reason'];
$date = date("y-m-d");
// SQL query to insert user data into the users table
$query= "INSERT INTO att(name, att, reason, date) VALUES('{$name}','{$att}','{$reason}','{$date}')";
$add_user = mysqli_query($conn,$query);
// displaying proper message for the user to see whether the query executed perfectly or not
if (!$add_user) {
echo "something went wrong ". mysqli_error($conn);
}
else {
}
}
?>
` please answer me fast i will be very thankful to you.
I expect that i should show mysql insert into statement also in a while loop so it adds new statements automatically based on number of rows it is recieving