1
I’m not getting a select to pull the data from the database, I wish someone could help me...
<!DOCTYPE html>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<center>
<h1>Adicionar ítem e categoria</h1>
<form action="adicionar_item.php" method="post">
<p><label for="item">ítem:</label>
<input type="text" name="item" id="item" autofocus></p>
<p><label for="categoria">Selecione a categoria:</label> <select name="categoria" id="categoria">
<option></option>
<?php
$sql="SELECT nome FROM categoria";
$resultado=$conexao->query($sql);
while($dados = $resultado->fetch_assoc()){
echo "<option value=".$dados['nome'].">".$dados['nome']."</option>";
}
?>
</select></p>
<input type="submit" value="Cadastrar">
</form>
</center>
</body>
</html>
what happens, makes some mistake, can explain better?
– Ricardo Pontual
select does not show the categories that are already in the database, select is empty
– overflow
your code seems correct to me, it just doesn’t show up where you initialized the connection variable
$conexao
– Ricardo Pontual
I managed to solve it, the problem was that I had not made the command to pull from the database. Now I’m facing new issues with adding the item in the database part
– overflow