i am trying to make an attendance chart in php. i wish to increment the counter of attendance in the database on click of a radio button. how do i retrieve the value and then increment for every "yes"?
do i need to put the updation code in the next page?
i tried it that way..but the fields are not getting updated..
if($class=="cse")
{
$result = mysqli_query($con, "SELECT * FROM cse");
echo "<table border=15px cellspacing=40>";
echo "<tr><th>NAME</th><th>BUPIN</th><th>ATTENDANCE</th></tr>";
while ($row = mysqli_fetch_array($result))
{
echo "<tr><td>" . $row["name"] . "</td>" . "<td>" . $row["bupin"] . "</td>";
echo "<td>" . "<input type='radio' name='presence[".$row["bupin"]."]' value='yes'>Yes";
echo "<input type='radio' name='presence[".$row["bupin"]."]' value='no'>No" . "</td></tr>";
}
echo "</table>";
?>
<html>
<form action= "final6.php" method="POST">
<input type="Submit" value="Submit">
</form>
</html>
}}
and the next page code is as:if (isset($_POST["presence"]))
{
foreach ($presence as $key => $val)
{
if ($val == 'yes')
{
$sql = "UPDATE cse SET 1attendance = 1attendance + 1 WHERE bupin = " .$key;
msyqli_query($con, $sql);
}
}
}
echo "Attendance marked successfully..";
}
where am i wrong?