Advertisement
Guest User

Untitled

a guest
Nov 6th, 2017
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html>
  4. <head>
  5. <meta lang="pl">
  6. <meta charset="utf-8">
  7. <title>Kurs</title>
  8.  
  9. </head>
  10. <body>
  11. <h1>Lista rekordów</h1>
  12. <?php
  13. include('db_connect.php');
  14. if($result = $mysqli->query("SELECT iducznia, imie, nazwisko, pesel FROM uczniowie ORDER BY iducznia")){
  15. if($result->num_rows > 0){
  16. echo "<table border='1' cellpadding='10'>";
  17. echo "<tr><th>Imie</th><th>Nazwisko</th><th>pesel</th></tr>";
  18. while($row = $result->fetch_object()){
  19. echo "<tr>";
  20. echo "<td>" . $row->imie . "</td>";
  21. echo "<td>" . $row->nazwisko . "</td>";
  22. echo "<td>" . $row->pesel . "</td>";
  23. echo "<td> <a href='records.php?iducznia=" . $row->iducznia . "'>Edytuj</a></td>";
  24. echo "<td> <a href='delete.php?iducznia=" . $row->iducznia . "'>Usuń</a></td>";
  25. echo "</tr>";
  26.  
  27. }
  28. echo "</table>";
  29. } else{
  30. echo "Brak rekordów";
  31. }
  32. }
  33. else
  34. {
  35. echo "Błąd: " . $mysqli->error;
  36. }
  37. $mysqli->close();
  38. ?>
  39. <a href="records.php">Dodaj nowego ucznia</a>
  40. </body></html>
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50. }
  51.  
  52.  
  53.  
  54. 2..
  55. <?php
  56. include('db_connect.php');
  57. if(isSet($_GET['iducznia']) && is_numeric($_GET['iducznia'])) {
  58. $id = $_GET['iducznia'];
  59. if($stmt = $mysqli->prepare("DELETE FROM uczniowie WHERE iducznia = ? LIMIT 1")){
  60. $stmt->bind_param("i",$id);
  61. $stmt->execute();
  62. $stmt->close();
  63. }else{
  64. echo "Błąd zapytania";
  65. }
  66. $mysqli->close();
  67. header("Location: index.php");
  68. }
  69. else{
  70. header("Location: index.php");
  71. }
  72.  
  73. ?>
  74.  
  75.  
  76. 3..
  77. <?php
  78.  
  79. $server = 'localhost';
  80. $user = 'root';
  81. $pass = 'admin123';
  82. $db = 'szkola';
  83.  
  84. $mysqli = new mysqli ($server, $user, $pass, $db);
  85.  
  86. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement