Guest User

Untitled

a guest
Jun 26th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php
  2.  
  3. //servidor
  4. $hostname = "localhost";
  5.  
  6. //usuario
  7. $username = "root";
  8.  
  9. //clave
  10. $password = "";
  11.  
  12. //aqui la base de datos
  13. $dbname = "test";
  14.  
  15. $conn = mysql_connect($hostname, $username, $password);
  16.  
  17. if (!$conn)
  18.  
  19. {
  20.  
  21. die('No pudo conectarse: ' . mysql_error());
  22.  
  23. }
  24.  
  25. mysql_select_db($dbname, $conn);
  26.  
  27.  
  28.  
  29. ?>
  30.  
  31. <!doctype html>
  32. <html>
  33. <head>
  34. <meta charset="utf-8">
  35. <title>checkbox dinamicos</title>
  36. </head>
  37.  
  38. <body>
  39.  
  40. <?php
  41.  
  42. include 'conexion.php';
  43.  
  44. $query = "SELECT id, nombre FROM empresas ";
  45.  
  46. $subject = mysql_query( $query, $conn );
  47. ?>
  48. <h2> CheckBox Dinamico</h2>
  49.  
  50. <form method="post" action=" ">
  51.  
  52. <?php
  53.  
  54. while($data = mysql_fetch_array($subject)) {
  55. //aqui imprimo o creo mi checkbox
  56. echo "<input type='checkbox' value='{$data['id']}'>" . $data['nombre'] . '</br>';
  57. }
  58.  
  59. ?>
  60.  
  61. </form>
  62.  
  63. </body>
  64. </html>
Add Comment
Please, Sign In to add comment