Hello everyone, I'm trying to make a form read MySql database options, but the line of code below shows me only the word "Array".
What is my error on this line? Can someone help me.
<form id="cadastro" action= "cadastroprodutos.php" method="post">
<p>Codigo<input type="text" name="codigo"size='14' maxlength="14" placeholder="Codigo"/></p>
Descrição<input type="text" name="descricao"size='50' maxlength="50" placeholder="Descrição"/>
<p>Cores<input type="text" name="cor"size="12" maxlength="12" placeholder="Cor"/>
Grupo <input list="grupo" name="grupo" size="10"/>
<?php
$sql= mysqli_query($conn,"select tipo from grupodeprodutos order by tipo");
$resp=mysqli_fetch_array($sql);
echo "<datalist id='grupo'><option value='$resp'></datalist>";
?>
Marca<input type="text" name="marca"size='20' maxlength="20" placeholder="Marca"/>
Preço<input type="text" name="preco"size='20' maxlength="20" placeholder="Preço"/></p>
<fieldset><legend>Campos Exclusivos para Moveis</legend>
<p>Valor de montagem:<input type="text" name="valorm"size='6'maxlength="6" placeholder="Valor de Montagem" value='' OnKeyPress="formatar('R$###,##' this)"/></fieldset></p>
<input type="submit"id="botao" name="botaoo" value="Salvar"/>
</form>
I modified the code for this pattern. As explained below.
Grupo <input list="grupo" name="grupo" size="10"/>
<?php
$sql= mysqli_query($conn,"select tipo from grupodeprodutos order by tipo");
while ($resp = mysqli_fetch_row($sql)) {
echo "<datalist id='grupo'><option value='" . $resp[0] . "'> </datalist>";
}
?>
Now the data is collected, but the last item in the table is always displayed, and I need everyone to appear. Thanks for any help.