Jump to content
Sign in to follow this  
cristpate

Visualizaçao e um drop down (php)

Recommended Posts

cristpate

oiiiiiii para todos

preciso de uma ajudinha

eu estou tentando exibir dados de um campo da tabela em mysql num drop down mas quando tento ele so me traz o ultimo dado, acho que e mais por causa do loop mas nao vejo outra maneira ja tentei nada

aqui vai o codigo

<?php

$host="localhost";

$username="root";

$password="";

$db_name="informatica";

$tbl_name="email_tecnico";

// Conexao com o servidor e selecionando a base de dados

mysql_connect("$host", "$username", "$password")or die("cannot connect");

mysql_select_db("$db_name")or die("cannot select Database");

$sql="select Id, Tec_email from email_tecnico";

$resultado=mysql_query($sql);

while($registo=mysql_fetch_array($resultado)){

$id=$registo['Id'];

$Tec_email=$registo['Tec_email'];

}

echo'<SELECT style="WIDTH: 300px" size=1 name=email></p><OPTION selected></OPTION>

    <OPTION>'.$Tec_email.'</OPTION>

  </SELECT>';

?>


craziness it's to do the same thing over and over again expecting a different result

Share this post


Link to post
Share on other sites
scorch

Vê se assim já dá.


<?php

$host="localhost";
$username="root";
$password="";
$db_name="informatica";
$tbl_name="email_tecnico";

// Conexao com o servidor e selecionando a base de dados

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select Database");


$sql="select Id, Tec_email from email_tecnico";

$resultado=mysql_query($sql);

echo'<SELECT style="WIDTH: 300px" size=1 name=email></p><OPTION selected></OPTION>';
while($registo=mysql_fetch_array($resultado)){

$id=$registo['Id'];
$Tec_email=$registo['Tec_email'];
       echo '<OPTION>'.$Tec_email.'</OPTION>';

}
echo '</SELECT>';



?>


scorch_pp.png

PS: Não respondo a perguntas por mensagem que podem ser respondidas no fórum.

Share this post


Link to post
Share on other sites
cristpate

boy dessa maneira o php nao ira reconhecer como um drop down ele precisa daqueles tags

<SELECTl>  <OPTION></OPTION> </SELECT>

para interpretar como um drop down menu ele ate nao exibe nada como output


craziness it's to do the same thing over and over again expecting a different result

Share this post


Link to post
Share on other sites
cristpate

SORRRRRRRRRRRRRRRRRRRRRRRRRRRRRY

eu e tinha feito uma burada dequelas  tinha trocado uma tag que puseste antes do while mas fui e verifiquei  FUNCIONOU SIMMMMMMM

muito obrigado a dias que eu tava a me bater a cabeça por causa desse codigo

obrigadissimo


craziness it's to do the same thing over and over again expecting a different result

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.