CRUD Mysql, I need a button that fills inputs

0

Good morning, I have a question about how to make the above inputs receive data from my database, for example: let's suppose I change something, but I just want to change a value to the cep (just an example) but to change it I need to know all the other values to not leave them blank, ie I want when I click on update the table be filled with the old values causing me to just have to edit: D

		
			<form action="editar.php" method="POST">
			<table class="table table-striped">
				<thead>
				<tr>
					<th>Cpf Novo</th>
					<th>Nome Novo</th>
					<th>Cep Novo</th>
					<th>Rua Novo</th>
					<th>Bairro Novo</th>
					<th>Cidade Novo</th>
					<th>Estado Novo</th>
					<th>Ibge Novo</th>
					</tr>
				</thead>
				
			<tbody>
			<tr>
				<td><input type="text" onclick="" class="form-control input-sm" id="cpf" name="cpf" required><br></td>
			
				<td><input type="text" class="form-control input-sm" name="nom" required><br></td>

				
				<td><input type="text" class="form-control input-sm" id="cep" name="end" required><br></td>
				
        		<td><input name="rua" class="form-control input-sm" type="text" id="rua" required /><br></td>
        		
        		<td><input name="bairro" class="form-control input-sm" type="text" id="bairro" required/><br></td>
        		
        		<td><input name="cidade" class="form-control input-sm" type="text" id="cidade" required/><br></td>
        		
        		<td><input name="uf" class="form-control input-sm" type="text" id="uf" required/><br></td>
        	
        		<td><input name="ibge" class="form-control input-sm" type="text" id="ibge" required/><br></td>
        	</tr>
        	</tbody>
        	</table>
				<br><input type="submit" class="btn btn-default"><input type="button" class="btn btn-warning" value="Voltar"
onclick="window.location='/Banco_de_dados/index.php';" />
			</form>


</body>
</html>

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "meubd";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
	die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT nome, cpf, cep, rua, bairro, cidade, estado, ibge FROM pessoas";
$result = $conn->query($sql);

?>
<div>
<table class="table table-striped" id="myTable">
	<thead>
		<tr>
			<th>CPF</th>
			<th>Nome</th>
			<th>Cidade</th>
			<th>estado</th>
			<th></th>
			<th></th>
		</tr>
	</thead>
	<tbody>
		<?php 
		while ($row = mysqli_fetch_array($result)){
		
		
		?>
		<tr>
			<td><?=$row['cpf']?></td>
			<td><?=$row['nome']?></td>
			<td><?=$row['cidade']?></td>
			<td><?=$row['estado']?></td>
			<td><input type="button" class="btn btn-danger" value="Delete"
onclick="window.location='/Banco_de_dados/delete.html';" /></td>
			<td><input type="button" class="btn btn-primary" value="Update"
onclick="window.location='/Banco_de_dados/editar.html';" /></td>	
		</tr>
		<?php 
		}
		?>
	</tbody>
</table>
</div>
    
asked by anonymous 03.05.2016 / 15:36

0 answers