xhpotterx Posted April 8, 2013 at 04:24 PM Report #502183 Posted April 8, 2013 at 04:24 PM Boas Como posso meter uma combobox a tomar os valores de dados que entam numa base de dados?
Solution NunoDinis Posted April 8, 2013 at 06:06 PM Solution Report #502215 Posted April 8, 2013 at 06:06 PM Assim: <select name="fornec_id"> <?php $sql="SELECT * from TABELA"; $lista=mysql_query($sql); while($liista=mysql_fetch_array($lista)) { echo "<option value=$liista[0]>"; $nn=$liista[1]; echo $nn." </option>"; } ?> </select> Estranha forma de vida que tem a capacidade de transformar comandos em mensagens de erro. ndsotware.org
HappyHippyHippo Posted April 8, 2013 at 10:56 PM Report #502256 Posted April 8, 2013 at 10:56 PM Assim: <select name="fornec_id"> <?php $sql="SELECT * from TABELA"; $lista=mysql_query($sql); while($liista=mysql_fetch_array($lista)) { echo "<option value=$liista[0]>"; $nn=$liista[1]; echo $nn." </option>"; } ?> </select> não podes responder sem saber que modelo/biblioteca de interacção com a base de dados ele usa ... IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
security Posted April 10, 2013 at 08:04 PM Report #502627 Posted April 10, 2013 at 08:04 PM (edited) e se quiseres selecionar um item especifico basta um "if" do genero: <select name="op"> <?php $sql = "SELECT * FROM tb_operacao"; $rs = mysql_query($sql); while ($o = mysql_fetch_array($rs)){ /* Carrega os dados na combobox */ if ($opid == $o['ID_op']){ /* Verifica se existe um valor na cmb = selecionado */ echo '<option value="'.$o['ID_op'].'" selected>'.$o['abv'].' - '.$o['descricao'].'</option>'; /* Se opção TRUE */ } else { echo '<option value="'.$o['ID_op'].'">'.$o['abv'].' - '.$o['descricao'].'</option>'; /* Se opção FALSE */ } } ?> </select> Edited April 10, 2013 at 08:06 PM by security "Innovation distinguishes between a leader and a follower." Steve jobs.
xhpotterx Posted April 11, 2013 at 09:01 AM Author Report #502690 Posted April 11, 2013 at 09:01 AM Obrigado a Todos o roblema ja foi resolvido;
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