1
I have a DIV call ( meusBotoes
) and I would like every loop
of while
generates a button inside the DIV
with the value of the variable $nome
and with the onclick
calling function display().
Man while
<?php
$host = "";
$bd = "";
$usr = "";
$psw = "";
$conn = new mysqli($host, $usr, $psw, $bd);
if ($conn->connect_error)
{
die("A conexão falhou, consulte o suporte: " . $conn->connect_error);
}
$sql = "SELECT id, nome, tipo, imagem FROM produtos";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
$id = $row['id'];
$nome = $row['nome'];
$tipo = $row['tipo'];
$imagem = $row['imagem'];
}
}
?>
There is an easy way to do this in PHP
same, without Javascript
?
What have you tried? It talks about writing inside a DIV, but it doesn’t show you in the code where it is. If your PHP returns an HTML, it’s just a matter of doing an echo '<input type="button" ...' with each iteration, or incrementing a variable with these inputs to give an echo in DIV later in the code...
– nunks