Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta lang="pl">
- <meta charset="utf-8">
- <title>Kurs</title>
- </head>
- <body>
- <h1>Lista rekordów</h1>
- <?php
- include('db_connect.php');
- if($result = $mysqli->query("SELECT iducznia, imie, nazwisko, pesel FROM uczniowie ORDER BY iducznia")){
- if($result->num_rows > 0){
- echo "<table border='1' cellpadding='10'>";
- echo "<tr><th>Imie</th><th>Nazwisko</th><th>pesel</th></tr>";
- while($row = $result->fetch_object()){
- echo "<tr>";
- echo "<td>" . $row->imie . "</td>";
- echo "<td>" . $row->nazwisko . "</td>";
- echo "<td>" . $row->pesel . "</td>";
- echo "<td> <a href='records.php?iducznia=" . $row->iducznia . "'>Edytuj</a></td>";
- echo "<td> <a href='delete.php?iducznia=" . $row->iducznia . "'>Usuń</a></td>";
- echo "</tr>";
- }
- echo "</table>";
- } else{
- echo "Brak rekordów";
- }
- }
- else
- {
- echo "Błąd: " . $mysqli->error;
- }
- $mysqli->close();
- ?>
- <a href="records.php">Dodaj nowego ucznia</a>
- </body></html>
- }
- 2..
- <?php
- include('db_connect.php');
- if(isSet($_GET['iducznia']) && is_numeric($_GET['iducznia'])) {
- $id = $_GET['iducznia'];
- if($stmt = $mysqli->prepare("DELETE FROM uczniowie WHERE iducznia = ? LIMIT 1")){
- $stmt->bind_param("i",$id);
- $stmt->execute();
- $stmt->close();
- }else{
- echo "Błąd zapytania";
- }
- $mysqli->close();
- header("Location: index.php");
- }
- else{
- header("Location: index.php");
- }
- ?>
- 3..
- <?php
- $server = 'localhost';
- $user = 'root';
- $pass = 'admin123';
- $db = 'szkola';
- $mysqli = new mysqli ($server, $user, $pass, $db);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement