This is the table
<table class="table table-bordered">
<thead>
<tr>
<th><strong>Description</strong></th>
<th><strong>Maximum Vote</strong></th>
<th><strong>Actions</strong></th>
</tr>
<?php
$sql ="SELECT * FROM positions ORDER BY priority ASC";
$result = mysqli_query($conn, $sql);
mysqli_close($conn);
while ($rows=$result->fetch_assoc())
{
?>
</thead>
<tbody>
<tr>
<td>
<i class="fab fa-angular fa-lg text-danger me-3"></i> <strong><?php echo $rows['description'];?></strong>
</td>
<td><?php echo $rows['max_vote'];?></td>
<td>
<button
type="button"
class="btn btn-sm btn-primary"
data-bs-toggle="modal"
data-bs-target="#edit"
data-id='<?php echo $rows['id']; ?>'
>
<i class="bx bx-edit-alt me-1"></i>Edit
</button>
<button
type="button"
class="btn btn-sm btn-danger"
data-bs-toggle="modal"
data-bs-target="#delete"
data-id='<?php echo $rows['id']; ?>'>
<i class="bx bx-trash me-1"> </i>Delete
</button>
</td>
</tr>
</tbody>
<?php
}
?>
</table>
And this is the modal I’m using
<div class="container mt-3">
<div class="col-lg-4 col-md-6">
<div class="mt-3">
<!-- Modal -->
<div class="modal fade" id="edit" tabindex="-1" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel1">Edit Position</h5>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">
<div class="card mb-4">
<div class="card-body">
<form action="positions_edit.php?id=<?php echo $rows["id"]; ?>" method="post">
<input type="hidden" class="id" id="id" name="id"/>
<div class="mb-3">
<label class="form-label" for="description">Description</label>
<input type="text" class="form-control" id="description" name="description" value="<?php echo $rows['description'];?>" />
</div>
<div class="mb-3">
<label class="form-label" for="max_vote">Maximum Vote</label>
<input type="text" class="form-control" id="max_vote" name="max_vote" value="<?php echo $rows['max_vote'];?>" />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">
Close
</button>
<button type="submit" class="btn btn-danger" name="edit">Update</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- DELETE -->
<div class="container mt-3">
<div class="col-lg-4 col-md-6">
<div class="mt-3">
<!-- Modal -->
<div class="modal fade" id="delete" tabindex="-1" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel1">Deleting...</h5>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">
<div class="card mb-4">
<div class="card-body">
<form action="positions_delete.php?id=<?php echo $rows["id"]; ?>" method="post">
<div class="mb-3">
<div class="text-center">
<p>DELETE POSITION</p>
<strong><h2><?php echo $rows["description"]; ?></h2></strong>
</div>
<input type="hidden" class="id" id="id" name="id"/>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">
Close
</button>
<button type="submit" class="btn btn-danger" name="delete">Delete</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
I queried the from action of the modal but its seems the problem is still there.
so what I basically want to achieve is for any row I decide to delete, the modal should show the details of that particular row and make changes to that row. But in my case for any row I decide to edit or delete the modal shows details of the first row