Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title> Zadanie 6.1 </title>
  4. </head>
  5. <body>
  6.  
  7. <?php
  8. $servername = "localhost";
  9. $username = "root";
  10. $password = "";
  11. $dbname = "studenci";
  12.  
  13. $conn = new mysqli($servername, $username, $password, $dbname);
  14. if ($conn->connect_error) {
  15. die("Connection failed: " . $conn->connect_error);
  16. }
  17.  
  18.  
  19. $sql = "SELECT idstudent, imie, nazwisko, grupa FROM student";
  20. $result = $conn->query($sql);
  21.  
  22. echo "<table border='1'>";
  23. echo '<tr>';
  24. echo '<td> idstudent </td>';
  25. echo '<td> imie </td>';
  26. echo '<td> nazwisko </td>';
  27. echo '<td> grupa </td>';
  28.  
  29. echo '</tr>';
  30. if ($result->num_rows > 0) {
  31. while($row = $result->fetch_assoc()) {
  32. $id = $row['idstudent'];
  33. echo "<tr><td>" . $row["idstudent"]. " </td><td> " . $row["imie"]. " </td><td> " . $row["nazwisko"]. " </td><td> "
  34. .$row['grupa']. "</td>".'<td><a href="strona_usuwajaca_rekord.php?action=delete&id='.$id.'">Usuń</td></tr>';
  35. }
  36. } else {
  37. echo "0 results";
  38. }
  39.  
  40. echo '</table>';
  41.  
  42.  
  43.  
  44.  
  45. $conn->close();
  46. ?>
  47. <fieldset>
  48. <legend> Dodaj studenta </legend>
  49. <form action ="dodawanie.php" method ="POST">
  50. <input type="submit" value="dodaj studenta"><br>
  51. </form>
  52. </fieldset>
  53. </body>
  54. </html>
  55. ----------------------------------------------
  56. <html>
  57. <head>
  58. <title> Zadanie 6.1 </title>
  59. </head>
  60. <body>
  61.  
  62.  
  63. <?php
  64. $servername = "localhost";
  65. $username = "root";
  66. $password = "";
  67. $dbname = "studenci";
  68.  
  69. $conn = new mysqli($servername, $username, $password, $dbname);
  70. if ($conn->connect_error) {
  71. die("Connection failed: " . $conn->connect_error);
  72. }
  73.  
  74. if(isset($_POST['imie']) && isset($_POST['nazwisko']) && isset($_POST['grupa']))
  75. {
  76. $imie = $_POST['imie'];
  77. $nazwisko = $_POST['nazwisko'];
  78. $grupa = $_POST['grupa'];
  79.  
  80. $sql_dod = "INSERT INTO student VALUES('','$imie','$nazwisko','$grupa')";
  81. $result1 = $conn->query($sql_dod);
  82. header("Location: form1.php");
  83. }
  84.  
  85. $conn->close();
  86.  
  87. ?>
  88.  
  89. <fieldset>
  90. <legend> Dodaj studenta </legend>
  91. <form action ="dodawanie.php" method ="POST">
  92. imie:<input type="text" name="imie"><br>
  93. nazwisko:<input type="text" name="nazwisko"><br>
  94. grupa:<input type="text" name="grupa"><br>
  95. <input type="submit" value="zapisz"><br>
  96. </form>
  97. </fieldset>
  98. </body>
  99. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement