Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 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. //Te conectas a tu base de datos Ej:
  18.  
  19. $link=conectarse();
  20.  
  21. //Realizas tu consulta SQL Ej:
  22.  
  23. $result=mysql_query("select nomdocente from docente",$link);
  24.  
  25. //Llenas el combo
  26.  
  27. if ($row = mysql_fetch_array($result)){
  28. echo '<select name="docente">';
  29. do {
  30.        echo '<option value= "'.$row["nomdocente"].'">'.$row["nomdocente"].'</option>';
  31. } while ($row = mysql_fetch_array($result));
  32. echo "</select>";
  33.  
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement