I have written a php code to display data as a table, using the values come from a MySQL database. I am adding 2 buttons to end of each row, 'Approve' and 'Reject' for example. It's something like this:
<?php
$con2=mysqli_connect ("localhost","root","","leavemanagement");
$res=mysqli_query($con2,"SELECT c.* , p.* FROM leaveapplication c,emp p WHERE c.empno=p.empno");
while($row=mysqli_fetch_array($res))
{
?>
<tr>
<td><p><?php echo $row['empno']; ?></p></td>
<td><p><?php echo $row['name']; ?></p></td>
<td><p><?php echo $row['dept']; ?></p></td>
<td><p><?php echo $row['startdate']; ?></p></td>
<td><p><?php echo $row['enddate']; ?></p></td>
<td><p><?php echo "<input type='submit' name='action' value='Approve' /><input type='submit' name='action' value='Reject' />" ?></p></td>
</tr>
<?php
}
?>
How can I perform an action based on each button click? For example if the user clicks 'Approve' button on 4th row, it should pick 'empno', 'startdate', 'enddate' of that row, so I can pass that data to update the database.