<?php
$db = mysqli_connect('localhost', 'root', '', 'medica');
?>
<!doctype html>
<html lang="pl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Przychodnia Medica</title>
    <link rel="shortcut icon" href="obraz2.png" type="image/x-icon">
    <link rel="stylesheet" href="styl.css">
</head>
<body>
<header>
    <h1>Abonamenty w przychodni Medica</h1>
</header>
<article>
    <?php
        $sql1 = "SELECT nazwa,cena,opis from abonamenty;";
        $result = mysqli_query($db, $sql1);
        while ($row = mysqli_fetch_assoc($result)) {
            echo "<h3>Pakiet " . $row['nazwa'] . " - cena " . $row['cena'] . " zł</h3>";
            echo "<p>" . $row['opis'] . "</p>";
        }
    ?>
    <a href="opis.html">Dowiedz się więcej</a>
</article>
<main>
    <section id="section_1" class="section">
        <h2>Standardowy</h2>
        <?php
        $sql2 = "SELECT nazwa, cecha FROM abonamenty JOIN szczegolyabonamentu ON abonamenty.id = Abonamenty_id JOIN cechy ON cechy.id = Cechy_id WHERE abonamenty.id = 1;";
        $result2 = mysqli_query($db, $sql2);
        echo "<ul>";
        while ($row = mysqli_fetch_assoc($result2)) {
            echo "<li>" . $row['nazwa'] . " - " . $row['cecha'] . "</li>";
        }
        ?>
    </section>
    <section id="section_2" class="section">
        <h2>Premium</h2>
        <?php
        $sql3 = "SELECT nazwa, cecha FROM abonamenty JOIN szczegolyabonamentu ON abonamenty.id = Abonamenty_id JOIN cechy ON cechy.id = Cechy_id WHERE abonamenty.id = 2;";
        $result3 = mysqli_query($db, $sql3);
        echo "<ul>";
        while ($row = mysqli_fetch_assoc($result3)) {
            echo "<li>" . $row['nazwa'] . " - " . $row['cecha'] . "</li>";
        }
        ?>
    </section>
    <section id="section_3" class="section">
        <h2>Dziecko</h2>
        <?php
        $sql4 = "SELECT nazwa, cecha FROM abonamenty JOIN szczegolyabonamentu ON abonamenty.id = Abonamenty_id JOIN cechy ON cechy.id = Cechy_id WHERE abonamenty.id = 3;";
        $result4 = mysqli_query($db, $sql4);
        echo "<ul>";
        while ($row = mysqli_fetch_assoc($result4)) {
            echo "<li>" . $row['nazwa'] . " - " . $row['cecha'] . "</li>";
        }
        ?>
    </section>
</main>
<footer>
    <p><img src="obraz2.png" alt="przychodnia">Stronę przygotował: Jakub Grzegorczyk 3p/1</p>
</footer>
</body>
</html>
<?php
mysqli_close($db);