Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title> Zadanie 6.1 </title>
- </head>
- <body>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "studenci";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT idstudent, imie, nazwisko, grupa FROM student";
- $result = $conn->query($sql);
- echo "<table border='1'>";
- echo '<tr>';
- echo '<td> idstudent </td>';
- echo '<td> imie </td>';
- echo '<td> nazwisko </td>';
- echo '<td> grupa </td>';
- echo '</tr>';
- if ($result->num_rows > 0) {
- while($row = $result->fetch_assoc()) {
- $id = $row['idstudent'];
- echo "<tr><td>" . $row["idstudent"]. " </td><td> " . $row["imie"]. " </td><td> " . $row["nazwisko"]. " </td><td> "
- .$row['grupa']. "</td>".'<td><a href="strona_usuwajaca_rekord.php?action=delete&id='.$id.'"><img src= cross.png width = 30px height = 30px></img></td></tr>';
- }
- } else {
- echo "0 results";
- }
- echo '</table>';
- $conn->close();
- ?>
- <fieldset>
- <legend> Dodaj studenta </legend>
- <form action ="dodawanie.php" method ="POST">
- <input type="submit" value="dodaj studenta"><br>
- </form>
- </fieldset>
- </body>
- </html>
- -----------------------------------------------------------
- --------------------------------------------------------------
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "studenci";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- if ($_GET['action']=='delete' && isset($_GET['id'])) {
- $id = (int) $_GET['id'];
- $zapytanie = "DELETE FROM student WHERE idstudent = {$id}";
- $conn->query($zapytanie);
- header("Location: form1.php");
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement