Untitled
unknown
plain_text
4 months ago
2.8 kB
2
Indexable
<?php $conn = mysqli_connect("localhost", "root", "", "4ti_kursy"); $q_sel = "SELECT * FROM kursy"; $results = mysqli_query($conn, $q_sel); ?> <!DOCTYPE html> <html lang="pl"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="styl.css"> </head> <body> <header> <h1>KURSY</h1> </header> <div id="left-panel"> <h2>Lista:</h2> <ol id="lista"> <?php while ($row = mysqli_fetch_assoc($results)) { $id = $row["id"]; $nazwa = $row["nazwa"]; echo "<li>$nazwa</li>"; } ?> </ol> </div> <div id="right-panel"> <h2>Zapisz się:</h2> <form id="registration-form" method="POST"> <label for="nazwa">Imię i nazwisko</label><br> <input type="text" id="nazwa" name="nazwa" placeholder="Wpisz imie i nazwisko" required> <br> <label for="numer_kursu">Numer kursu:</label><br> <input type="number" id="numer_kursu" name="numer_kursu" placeholder="Wybierz numer kursu (1-3)"> <br> <button type="submit" name="dodaj" id="dodaj">Zapisz</button> </form> <?php if (isset($_POST["dodaj"])) { $nazwa = $_POST['nazwa']; $nr_kursu = $_POST['numer_kursu']; $select_id = "SELECT nazwa from kursy where id = '$nr_kursu' "; $wynik = mysqli_query($conn, $select_id); $kurs = mysqli_fetch_assoc($wynik); $nazwakursu = $kurs['nazwa']; echo "UCZESTNIK $nazwa zapisal sie na kurs : $nazwakursu "; } ?> </div> <div id="stopka"> <footer> <p>PESEL:000000000000</p> </footer> </div> </body> </html> <?php mysqli_close($conn) ?> * { box-sizing: border-box; } header { height: 100px; background-color: red; text-align: center; color: white; font-size: 36px; line-height: 100px; } #right-panel { width: 60%; height: 450px; background-color: yellow; padding: 20px; float: right; } #left-panel { width: 40%; height: 450px; background-color: lightgreen; padding: 20px; float: left; } button { padding: 10px; background-color: #4CAF50; color: white; border: none; cursor: pointer; } button:hover { background-color: #45a049; } #stopka{ background-color: black; float: inline-end; height: 60px; text-align: center; width: 100%; color: white; }
Editor is loading...
Leave a Comment