2
Hello Folks I am trying to make a form read Mysql database options, however the code line below shows me only the word "Array".
What is my mistake in this line? Can anyone 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 of the table is always displayed, and I need everyone to appear. I appreciate any help.
Thanks your tips were very useful, but it didn’t work at first. But I switched ($Resp = mysqli_fetch_array($sql)) to ($Resp = mysqli_fetch_row($sql)) and ran perfectly.
– Danilo Araujo
Hi Amigo had the problem after, the form only displayed the last table item
– Danilo Araujo