Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

Sign in to follow this  
Duke11

[Ajuda] Como ligar uma combobox a BD em php?

Recommended Posts

Duke11
Alquem me diz como ligo a ultima combobox a BD?

queria ligar a combobox  material á BD para apareçer na combobox o material que eu inserir na BD

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>


<p align="center" class="style1"> Requisições      
      <p align="right">
               <script type="text/javascript">
               function UR_Start()
               {
                  UR_Nu = new Date;
                  UR_Indhold = showFilled(UR_Nu.getHours()) + ":" + showFilled(UR_Nu.getMinutes()) + ":" + showFilled(UR_Nu.getSeconds());
                  document.getElementById("ur").innerHTML = UR_Indhold;
                  setTimeout("UR_Start()",1000);
               }
               function showFilled(Value)
               {
                  return (Value > 9) ? "" + Value : "0" + Value;
               }
               
               </script>


<font id="ur" size="4" face="Trebuchet MS, Verdana, Arial, sans-serif" color="#DAD3B7"></font>

<body onLoad="UR_Start()">
<p>      
     <form id="form1" name="form1" method="post" action="">
       
     
      <label><span class="style13">Data
      <input readonly="readonly" name="select1" id="select1"  onclick="displayDatePicker('select1', false, 'dmy', '.');" onfocus="this.style.backgroundColor='#EEEEEE'" onblur="this.style.backgroundColor=''" value="" style=" width:100px; margin-left:22px"/>
</span></label>
        <p> </p>
        <p><img src="img/material.jpg" width="234" height="172" align="right" longdesc="img/material.jpg" /></p>
        <p> </p>
        <p>
          <label><span class="style13">Hora</span>
          <select name="select2" style=" width:100px; margin-left:20px">
          </select>
          </label>
        </p>  
        <p></p>
        </p>
        <p> </p>
        <p>             </p>
          <p> </p>
        <p>
          <label><span class="style13">Material</span>
          <select name="select3" style=" width:150px">
          </select>
          </label>
        </p>
        <p align="center"> </p>
        <p align="center"> </p>
        <p align="left">
           <input name="ok" type="submit" id="ok" value="Ok"/>
        </p>
        <p align="left"> </p>
        <p align="left"> </p>
     </form>      <p>      
      <p>



</body>
</html>

Nome da Base de dados = pap


Nome: Utilizador
Cod_utilizador
Nome_utilizador
Password
Login


Nome: Requisicao
Cod_requisicao; 
data_requisicao;
Data_levantamento;
hora_levantamento; 
hora_entrega;
cod_utilizador;
cod_destino;
cod_material;
entregue;


Nome: Destino
cod_destino;
nome_destino;
Nome: Material
cod_material;
designacao_material;
Quantidade;


http://www.fmxpert360.com

Share this post


Link to post
Share on other sites
gambas

assumindo que estas a falar de uma bd em mysql, entre as tags select colocas o seguinte codigo:

<?php 

mysql_connect("o teu servidor","o teu utilizador","a tua password");
mysql_select_db("no teu caso -> pap");

$sql="select * from Material";
$res=mysql_query($sql);

while($row=mysql_fetch_object){
echo "<option value='".$row->cod_material."'>".$row->designacao_material."</option>";
}
?>

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

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.