I was trying to name my submit buttons by fetched data from the database using a while loop. but I don't know how to name it and put it in an isset($_POST[] method. here is my code.
<form method="POST" action="" enctype="multipart/form-data">
<?php
$stats = $conn->query("SELECT * FROM recruitment_status order by id asc");
while ($row = $stats->fetch_assoc()) :
$status_label=$row['status_label'];
?>
<div class="row">
<div class="col-md-12 form-group">
<button class="btn-block btn-sm btn filter_status" type="submit" name="<?php echo $status_label ?>"><?php echo $status_label ?></button>
</div>
</div>
<?php endwhile; ?>
</form>
if(ISSET($_POST[$status_label]))
{
echo $row['status_label'];
}
htmlspecialchars()to output all values in HTML to prevent XSS.