Advertisement
Guest User

Untitled

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