Witam uczę się i trafiłem na problem z którym nie jestem w stanie sobie poradzić a więc tak. Chce pobrać id z listy użytkowników i edytować cały rekord i zamiast pobrania tego konkretnego id co klikam to pobiera mi wszystkie id i wczytuje mi ostatni rekord (id).
Kod z formularza do wysłania do edycji:
<form action="register_edit.php" method="post">
<input type="text" name="edit_id" value="<?php echo $row['id']; ?>">
<button type="submit" name="edit_btn" class="btn btn-success">Edycja</button>
</td>
<td>
<button type="submit" class="btn btn-danger">Usuń</button>
</td>
kod z edycji gdzie dane zostały wysłane:
<?php
//edycja usera
if(isset($_POST['edit_btn']))
{
$id=$_POST['edit_id'];
$query = "SELECT * FROM register WHERE id = '$id'";
$query_run = mysqli_query(getConnection(), $query);
foreach($query_run as $row)
{
?>
<div class="form-group">
<label> Username </label>
<input type="text" name="username" value="<?php echo $row['username']; ?>" class="form-control" placeholder="Enter Username">
</div>
<div class="form-group">
<label>Email</label>
<input type="email" name="email" value="<?php echo $row['email']; ?>" class="form-control" placeholder="Enter Email">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" name="password" value="<?php echo $row['password']; ?>" class="form-control" placeholder="Enter Password">
</div>
<?php
}
}
?>