Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="pl">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Dziennik szkolny</title>
  6.  
  7. <meta http-equiv="X-Ua-Compatible" content="IE=edge">
  8. <link rel="stylesheet" href="main.css">
  9.  
  10. </head>
  11.  
  12. <body>
  13.  
  14. <form action="index.php" method="post">
  15.  
  16.  
  17.  
  18.  
  19.  
  20. </form>
  21.  
  22. <?php
  23.  
  24. if(isset($_POST["klient"]))
  25. {
  26.  
  27. if(empty($_POST["klient"]))
  28. {
  29. echo '<span style="color:yellow;">Nie podano nazwy klasy!</span>';
  30. }
  31. else
  32. {
  33. require_once "connect.php";
  34.  
  35. $conn = mysqli_connect($host, $user, $pass, $db) or die("Błąd połączenia!");
  36.  
  37. mysqli_set_charset($conn, "utf8");
  38.  
  39.  
  40.  
  41. $klient = $_POST["klient"];
  42.  
  43. $q = "SELECT Imie, Nazwisko FROM klient";
  44.  
  45. $result = mysqli_query($conn, $q) or die("Problemy z odczytem danych!");
  46.  
  47. $ile = mysqli_num_rows($result);
  48.  
  49. if($ile == 0)
  50. {
  51. echo '<span style="color:red;">Nie ma takiej klasy w szkole!</span>';
  52. }
  53. else
  54. {
  55.  
  56. echo<<<END
  57.  
  58. <table>
  59. <thead>
  60. <tr>
  61. <th>Imię</th>
  62. <th>Nazwisko</th>
  63.  
  64. </tr>
  65. </thead>
  66. <tbody>
  67.  
  68. END;
  69. $suma = 0;
  70.  
  71. while($row = mysqli_fetch_assoc($result))
  72. {
  73. echo "\r\n\t\t\t<tr>";
  74. foreach($row as $col)
  75. {
  76. echo "<td>$col</td>";
  77.  
  78. }
  79. echo "</tr>";
  80.  
  81.  
  82.  
  83. //echo "\r\n\t\t\t<tr><td>".$row['Imie']."</td><td>".$row['Nazwisko']."</td></tr>";
  84. }
  85. echo<<<END
  86. \r\n
  87. </tbody>
  88. </table>
  89. END;
  90.  
  91.  
  92.  
  93. }
  94.  
  95. mysqli_close($conn);
  96.  
  97. }
  98.  
  99.  
  100. }
  101.  
  102.  
  103.  
  104. ?>
  105.  
  106. </body>
  107. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement