Advertisement
Guest User

Untitled

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