Calling a database key for a user to choose in a Php form

Asked

Viewed 46 times

0

<?php
$link = mysqli_connect("localhost", "root", "");
$query = mysqli_query($link, "certificados");
?>
<form name="produto" method="post" action="">
 <label for="">Selecione um Nome de Autor</label>
 <select>
 <option>Selecione...</option>

 <?php while($prod = mysqli_fetch_array($query)) { ?>
 <option value="<?php echo $prod["aut_nome"] ?>"</option>
 <?php } ?>

Because this code does not work does not appear database data to choose thank you!!!

  • 2

    You are giving command of "certificates", I believe it would be at least "SELECT * FROM certificados", see http://www.w3schools.com/sql/sql_select.asp.

1 answer

1

Also missing hit the option tag <option value="<? php echo $Prod["aut_name"] ? >"><? php echo $Prod["aut_name"] ? ></option>

<?php
$link = mysqli_connect("localhost","USUARIO","SENHA","DB");
$query = ("SELECT * FROM certificados");
$resultado_pedido = mysqli_query($link,$query);
?>
<form name="produto" method="post" action="">
<label for="">Selecione um Nome de Autor</label>
<select>
<option>Selecione...</option>
<?php while($prod = mysqli_fetch_array($resultado_pedido)) { ?>
<option value="<?php echo $prod["aut_nome"] ?>"><?php echo $prod["aut_nome"] ?></option>
<?php } ?>
</select>
</form>

  • I tested on my server and running round

Browser other questions tagged

You are not signed in. Login or sign up in order to post.