Valadas Posted May 27, 2009 at 01:04 PM Report #267671 Posted May 27, 2009 at 01:04 PM Boas pessoal, estou a criar uma form em HTML onde incluio a tag <select> e quero preencher a droplist com os dados vindos de uma base de dados. Nunva fiz isto, e pelo que pesquisei não ajuda muito. Tenho o seguinte código: <b>ADICIONAR</b> <form method="POST" action="adiccateg2.php" enctype="multipart/form-data" > <ul> <li>Pai: <select name="pai"><option>Nenhum</option> <?php $ligacao=mysql_connect("localhost", "estagios", "estagios"); if (!$ligacao) { print ("Problema na ligação!"); } $sql="select nome from categorias"; $resultado=mysql_db_query("estagios",$sql); while ($registo=mysql_fetch_array($resultado)) { $nome=$registo["nome"]; } ?> <option>$sql</option> </li> </select> <br/> <li>Nome: <input type="text" name="nome" size="12"></li> <br/> </ul> <p align="left"><input type="submit" value="adicionar registo"> <input type="reset" value="limpar ecra"> <p align="center"> </p> </form> Uma ajudinha, adradecia!! 😞 RV
Valadas Posted May 27, 2009 at 01:36 PM Author Report #267686 Posted May 27, 2009 at 01:36 PM Resolvido! <b>ADICIONAR</b> <form method="POST" action="adiccateg2.php" enctype="multipart/form-data" > <ul> <li>Pai: <select name="pai"><option>Nenhum</option> <?php mysql_connect("localhost", "estagios", "estagios") or die ("Problema na ligação!"); $sql="select nome from categorias"; $resultado=mysql_db_query("estagios",$sql); while ($registo=mysql_fetch_array($resultado)) { $nome=$registo["nome"]; echo '<option>' . $nome . '</option>'; } ?> </li> </select> <br/> <li>Nome: <input type="text" name="nome" size="12"></li> <br/> </ul> <p align="left"><input type="submit" value="adicionar registo"> <input type="reset" value="limpar ecra"> <p align="center"> </p> </form> RV
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now