Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INDEX CHUJU
- <!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 * FROM uczniowie ORDER BY id_ucz")){
- if($result->num_rows > 0){
- echo "<table border='1' cellpadding='10'>";
- echo "<tr><th>id_ucz</th><th>nazwisko</th></tr>";
- while($row = $result->fetch_object()){
- echo "<tr>";
- echo "<td>" . $row->id_ucz . "</td>";
- echo "<td>" . $row->Nazwisko . "</td>";
- echo "<td> <a href='records.php?id_ucz=" . $row->id_ucz . "'>Edytuj</a></td>";
- echo "<td> <a href='delete.php?id_ucz=" . $row->id_ucz . "'>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>
- DBCONNECT KURWIU
- <?php
- //plik zapisany pod nazwą db_connect.php
- $server = 'localhost';
- $user = 'root';
- $pass = '';
- $db = 'szkola2';
- $mysqli = new mysqli ($server,$user,$pass,$db)
- ?>
- DELETE MIŁY KUMPLU
- <?php
- include('db_connect.php');
- if (isset($_GET['id_ucz']) && is_numeric($_GET['id_ucz'])) {
- $id = $_GET['id_ucz'];
- if($stmt = $mysqli->prepare("DELETE FROM uczniowie WHERE id_ucz = ? 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");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement