Guest User

Untitled

a guest
Jul 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. <?php
  2. require_once 'conexion.php';
  3.  
  4. if (isset($_POST['enviar_estudiante'])) {
  5. $ced = $_POST['cedula'];
  6. $nombre = $_POST['nombre'];
  7.  
  8. echo $ced . $nombre;
  9.  
  10.  
  11.  
  12. $sql = "INSERT INTO pagos.estudiante(est_cedula, est_apellido)
  13. VALUES (" . "'" . $ced . "','" . $nombre . "'" . ")";
  14. $result = pg_query($dbconn, $sql);
  15.  
  16. if(!$result){
  17. echo pg_last_error($dbconn);
  18. } else {
  19. echo "Updated successfully";
  20. }
  21.  
  22.  
  23. }
  24.  
  25.  
  26. if (isset($_POST['consultar'])) {
  27. $result = pg_query($dbconn, "SELECT * FROM pagos.estudiante");
  28. if (!$result) {
  29. echo "An error occurred.\n";
  30. exit;
  31. }
  32.  
  33. echo "<table>\n";
  34. while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
  35. echo "\t<tr>\n";
  36. foreach ($line as $col_value) {
  37. echo "\t\t<td>$col_value</td>\n";
  38. }
  39. echo "\t</tr>\n";
  40. }
  41. echo "</table>\n";
  42.  
  43. // Liberando el conjunto de resultados
  44. pg_free_result($result);
  45.  
  46.  
  47.  
  48. }
  49.  
  50.  
  51.  
  52. if (isset($_POST['actualizar'])) {
  53. $ced = $_POST['cedula'];
  54. $nombre = $_POST['nombre'];
  55. $sql = "update pagos.estudiante set est_nombre = " . "'" . $nombre . "'" . " where est_cedula = " . "'" . $ced . "'";
  56.  
  57. $result = pg_query($dbconn, $sql);
  58. if(!$result){
  59. echo pg_last_error($dbconn);
  60. } else {
  61. echo "Updated successfully.";
  62. }
  63. }
  64.  
  65.  
  66.  
  67.  
  68. if (isset($_POST['eliminar'])) {
  69. $ced = $_POST['cedula'];
  70. $sql = "delete from pagos.estudiante where est_cedula = " . "'" . $ced . "'";
  71.  
  72. $result = pg_query($dbconn, $sql);
  73. if(!$result){
  74. echo pg_last_error($dbconn);
  75. } else {
  76. echo "Deleted successfully\n";
  77. }
  78.  
  79. }
  80.  
  81.  
  82.  
  83.  
  84.  
  85. // Close the connection
  86. pg_close($dbconn);
  87.  
  88.  
  89.  
  90.  
  91.  
  92. ?>
Add Comment
Please, Sign In to add comment