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 1.46 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title> Zadanie 6.1 </title>
  4. </head>
  5. <body>
  6.  
  7.  
  8. <?php
  9. $servername = "localhost";
  10. $username = "root";
  11. $password = "";
  12. $dbname = "studenci";
  13.  
  14. $conn = new mysqli($servername, $username, $password, $dbname);
  15. if ($conn->connect_error) {
  16. die("Connection failed: " . $conn->connect_error);
  17. }
  18.  
  19.  
  20. if(isset($_POST['imie']) && isset($_POST['nazwisko']) && isset($_POST['grupa']))
  21. {
  22. $imie = $_POST['imie'];
  23. $nazwisko = $_POST['nazwisko'];
  24. $grupa = $_POST['grupa'];
  25.  
  26. $sql_dod = "INSERT INTO student VALUES('','$imie','$nazwisko','$grupa')";
  27. $result1 = $conn->query($sql_dod);
  28. }
  29.  
  30.  
  31.  
  32. $sql = "SELECT idstudent, imie, nazwisko, grupa FROM student";
  33. $result = $conn->query($sql);
  34.  
  35. echo "<table border='1'>";
  36. echo '<tr>';
  37. echo '<td> idstudent </td>';
  38. echo '<td> imie </td>';
  39. echo '<td> nazwisko </td>';
  40. echo '<td> grupa </td>';
  41. echo '</tr>';
  42. if ($result->num_rows > 0) {
  43. while($row = $result->fetch_assoc()) {
  44. echo "<tr><td>" . $row["idstudent"]. " </td><td> " . $row["imie"]. " </td><td> " . $row["nazwisko"]. " </td><td> " .$row['grupa']. "</td></tr>";
  45. }
  46. } else {
  47. echo "0 results";
  48. }
  49. echo '</table>';
  50. $conn->close();
  51. ?>
  52. <fieldset>
  53. <legend> Dodaj studenta </legend>
  54. <form action ="form1.php" method ="POST">
  55. imie:<input type="text" name="imie"><br>
  56. nazwisko:<input type="text" name="nazwisko"><br>
  57. grupa:<input type="text" name="grupa"><br>
  58. <input type="submit" value="dodaj"><br>
  59. </form>
  60. </fieldset>
  61. </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement