Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. <?php
  2.   function conectarse()
  3.   {
  4.     if(!($link=mysql_connect("localhost","root","root")))
  5.     {
  6.         echo "Error conectando a la base de datos.";
  7.         exit();
  8.     }
  9.     if(!mysql_select_db("materialdocente",$link))
  10.     {
  11.         echo "Error seleccionando la base de datos.";
  12.         exit();
  13.     }
  14.     return $link;
  15.   }
  16.  
  17. function llenarcombo(){
  18.    
  19.  
  20. //Te conectas a tu base de datos Ej:
  21.  
  22. $link=conectarse();
  23.  
  24. //Realizas tu consulta SQL Ej:
  25.  
  26. $result=mysql_query("select nomdocente from docente",$link);
  27.  
  28. //Llenas el combo
  29.  
  30. if ($row = mysql_fetch_array($result)){
  31. echo '<select name="docente">';
  32. do {
  33.        echo '<option value= "'.$row["nomdocente"].'">'.$row["nomdocente"].'</option>';
  34. } while ($row = mysql_fetch_array($result));
  35. echo "</select>";
  36. }
  37.  
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement