I display records from the database in TDs, each record has an edit button that opens the edit screen, but I do not know how I can display the data in the record I clicked to edit and save.
I display records from the database in TDs, each record has an edit button that opens the edit screen, but I do not know how I can display the data in the record I clicked to edit and save.
From this site indicated by @ R.Santos , I followed the steps and arrived at the following code:
dados.php //(tela que exibe os registros do banco)
echo '<a href="edicao.php?id=' . $id . '"><button class="btn btn-default btn-xs"><i class="fa fa-pencil"></i></button></a>';
In this data screen I get the record id through the button.
edicao.php //(tela onde a o formulário de edição)
<?php
$id = $_GET['id'];
$conexao = mysqli_connect('', '', '', '');
<form class="form-horizontal tasi-form" method="POST" action="php/editar.php">
<input type="text" class="form-control" name="nome" required="required" value="<?php echo $exibe['nome'] ?>">
?>
In the edit screen I get this id that was passed by the url and start the connection, afterwards, I adjust the form that calls the edit file and organize the bank fields in the form fields.
editar.php //(update nos campos)
$id = $_POST['id'];
$conexao = mysqli_connect('', '', '', '');
$result = mysqli_query($conexao, "UPDATE pessoas SET id = '$id'
mysqli_close($conexao);
Finally, I update in the edited fields. For more details just go to website that has everything well explained.
On the button there should be an indication of which record you want to edit. For example: In record 1 in the button link should have something like (href="my-table / edit.php? Id = $ id-of-record")