Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.94 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>druzyny</title>
  4. </head>
  5. <body bgcolor="white">
  6.  
  7. <?php
  8. $link = pg_connect("host=labdb dbname=mrbd user=gb357712 password=x");
  9. $result = pg_query($link, "select * from druzyny");
  10. $numrows = pg_numrows($result);
  11. ?>
  12.  
  13. <h2 align=center>Nasze gatunki</h2>
  14.  
  15. <table border="1" align=center>
  16. <tr>
  17.  <th>Nazwa</th>
  18.  <th>Trener</th>
  19. </tr>
  20. <?php
  21.  
  22.  // Loop on rows in the result set.
  23.  
  24.  for($ri = 0; $ri < $numrows; $ri++) {
  25.   echo "<tr>\n";
  26.   $row = pg_fetch_array($result, $ri);
  27.   echo " <td>" . $row["Nazwa"] . "</td>
  28. <td>" . $row["Trener"] . "</td>
  29. </tr>
  30. ";
  31.  }
  32.  pg_close($link);
  33. ?>
  34. </table>
  35. </body>
  36. </html>
  37.  
  38.  
  39. <html>
  40. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  41. <title>Wstaw zawodnika</title>
  42. <body>
  43.  
  44. <?php
  45. $Nazwa = $_POST["Nazwa"];
  46. $Trener = $_POST["Trener"];
  47.  
  48.  
  49. $link = pg_connect("host=labdb dbname=mrbd user=gb357712 password=x");
  50. $wynik = pg_query($link,
  51.                   "INSERT INTO Druzyny VALUES ('"
  52.             . pg_escape_string($Nazwa) .
  53.                   "','" . pg_escape_string($Trener) . "')");
  54.  
  55. if ($wynik) {
  56.   echo "OK";
  57. }
  58. else {
  59.   echo "Nie udalo sie?!<br>";
  60.   echo pg_last_error($link) . "<br>";
  61. }
  62. ?>
  63.  
  64. </body>
  65. </html>
  66.  
  67.  
  68. <html>
  69. <head>
  70. <title>Zawodnicy</title>
  71. </head>
  72. <body bgcolor="white">
  73.  
  74. <?php
  75. $link = pg_connect("host=labdb dbname=mrbd user=gb357712 password=x");
  76. $result = pg_query($link, "select * from zawodnicy");
  77. $numrows = pg_numrows($result);
  78. ?>
  79.  
  80. <h2 align=center>Nasze gatunki</h2>
  81.  
  82. <table border="1" align=center>
  83. <tr>
  84.  <th>ID</th>
  85.  <th>Imie</th>
  86.  <th>Nazwisko</th>
  87.  <th>Druzyna</th>
  88. </tr>
  89. <?php
  90.  
  91.  // Loop on rows in the result set.
  92.  
  93.  for($ri = 0; $ri < $numrows; $ri++) {
  94.   echo "<tr>\n";
  95.   $row = pg_fetch_array($result, $ri);
  96.   echo " <td>" . $row["ID"] . "</td>
  97. <td>" . $row["Imie"] . "</td>
  98. <td>" . $row["Nazwisko"] . "</td>
  99. <td>" . $row["Druzyna"] . "</td>
  100. </tr>
  101. ";
  102.  }
  103.  pg_close($link);
  104. ?>
  105. </table>
  106. </body>
  107. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement