0
Hello, I want to do the following: I want the elements that are registered in the database to appear within a "Select - Option (FORM - HTML)".
Ex:
<body>
<?php
include("conexa.php");
$id = 80;
$pegadiv = $PDO->query("SELECT * FROM `dividas` WHERE id_user = '$id'");
while($linha = $pegadiv->fetch(PDO::FETCH_ASSOC)){
$idConta = $linha['id'];
$nomeConta = $linha['descricao'];
echo "<br>";
}
?>
<form method="post" action="action.php">
<select name="conta">
<option name="<?php $idConta ?>"> <?php echo $nomeConta?> </option>
</select>
<input type="submit" value="Excluir">
</form>
</body>
This is the way I’m doing it, only this way appears the last account listed by the user.
your options need to stay within while, the way it is you are getting some result?
– WMomesso
I get it. But only the last registered.
– Andre Junior
When I put inside the looping creates a select for each registered item
– Andre Junior
Did you come to test my code? as I mentioned before the option needs to be inside the looping, the <select> tag needs to be outside, respecting <select><looping></select>
– WMomesso