Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Zadanie 7.1.0</title>
- <meta charset="UTF-8">
- <meta http-equiv="refresh" content="1; http://localhost/SebastianBialuchaZad7_1_0.php" />
- </head>
- <body>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "baza danych";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT * from studenci";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- while($row = $result->fetch_assoc()) {
- echo $row["id"]. ". " . $row["imie"]. " " . $row["nazwisko"];
- ?>
- <a href="localhost/SebastianBialuchaZad7_1_0.php?id=$_GET['id']"><img src='crossmark.png' width='12' height='12' alt='crossmark'> </a><br>;
- <?php
- }
- } else {
- echo "0 results";
- }
- if(isset($_GET['id'])) {
- $delete_id = mysql_real_escape_string($_GET['id']);
- $sql = mysql_query("DELETE FROM studenci WHERE id = '".$delete_id."'");
- if($sql) {
- echo "<br/><br/><span>deleted successfully...!!</span>";
- } else {
- echo "ERROR";
- }
- }
- $conn->close();
- ?>
- <form action="SebastianBialuchaZad7_1_1.php" method="post">
- <input type="submit" value="Dodaj nowego studenta" />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement