Guest User

Untitled

a guest
Oct 25th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. <?php
  2. $host = "oraclepr.uco.es";
  3. $username = "i52calei";
  4. $password = "***";
  5. $database = "i52calei";
  6.  
  7. $conn = new mysqli ($host, $username, $password, $database);
  8. if ($conn->connect_error)
  9. die ($conn->connect_error);
  10.  
  11. $sql = "SELECT nombre, apellidos, edad, DNI, salario, telefono, direccion FROM empresa";
  12. ?>
  13.  
  14. <table border=1>
  15. <tr>
  16. <th>Nombre</th>
  17. <th>Apellidos</th>
  18. </tr>
  19.  
  20. <?php
  21. $rows = $conn->query($sql);
  22. if(!$rows)
  23. die($conn->error);
  24.  
  25. foreach($rows as $row){
  26. echo '<tr><td>'.$row["nombre"].'</td><td>'.$row["apellidos"].'</td><td><a href="detalles_empleado.php?nombre='.urlencode($row["nombre"]).'">Ver detalles</a></td></tr>';
  27. }
  28. echo "</table>";
  29. $conn = null;
  30. ?>
  31.  
  32. <?php
  33. $host = "oraclepr.uco.es";
  34. $username = "i52calei";
  35. $password = "***";
  36. $database = "i52calei";
  37.  
  38. $conn = new mysqli ($host, $username, $password, $database);
  39. if ($conn->connect_error)
  40. die ($conn->connect_error);
  41.  
  42. $sql = "SELECT * FROM empresa where nombre=".$_GET["nombre"];
  43.  
  44. $rows = $conn->query ($sql);
  45. if (!$rows)
  46. die ($conn->error);
  47.  
  48. $row=$rows->fetch_assoc ();
  49. ?>
  50.  
  51. <p><strong>Nombre: </strong><?php echo $row["nombre"]?></p>
  52. <p><strong>Apellidos: </strong><?php echo $row["apellidos"]?></p>
  53. <p><strong>Edad: </strong><?php echo $row["edad"]?></p>
  54. <p><strong>DNI: </strong><?php echo $row["DNI"]?></p>
  55. <p><strong>salario: </strong><?php echo $row["salario"]?></p>
  56. <p><strong>telefono: </strong><?php echo $row["telefono"]?></p>
  57. <p><strong>Direccion: </strong><?php echo $row["direccion"]?></p>
  58.  
  59. <br/>
  60.  
  61. <a href="empleados.php">Lista de Empleados</a>
  62. <?php
  63. $conn = null;
  64. ?>
  65.  
  66. echo '<tr><td>'.$row["nombre"].'</td><td>'.$row["apellidos"].'</td><td><a href="detalles_empleado.php?nombre='.urlencode($row["nombre"]).'">Ver detalles</a></td></tr>';
Add Comment
Please, Sign In to add comment