<!DOCTYPE html>
<html lang="tr">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <title>Kitap Kataloğu</title>
</head>

<body>
    <div class="alert alert-secondary" role="alert" style="max-width: 1000px; margin: 20px auto">
        <div class="col text-right" style="margin-bottom: 20px">
            <a href="index.php"><button type="button" class="btn btn-primary" style="margin:auto;">Ana Sayfaya Dön</button></a>
        </div>

        <?php
        require_once("_ayarlar.php");

        echo "<a href='katalog.php'><button class='btn btn-info'>Tüm Kitaplar</button></a> ";

        $sql = "SELECT DISTINCT tur FROM kitap";
        $tablo = $vt->query($sql);
        while ($satir = $tablo->fetch_assoc()) {
            $tur = $satir["tur"];
            echo "<a href='katalog.php?tur=$tur'><button class='btn btn-info'>$tur</button></a> ";
        }

        echo "<hr>";
        echo "<div class='row'>";
        $kategori = @$_GET["tur"];
        if($kategori == null) $sql = "SELECT * FROM kitap";
        else $sql = "SELECT * FROM kitap WHERE tur = '$kategori' ";
        $sonuc = $vt->query($sql);
        while ($satir = $sonuc->fetch_assoc()) {
            $resim = $satir["resim"];
            echo '<div class="col-md-3 mb-3">
                    <div class="card h-100">
                    <img src="kapak/' . $resim . '" class="card-img-top" alt="' . $satir["kitap_ad"] . '" style="height: 300px; object-fit: cover;">
                    <div class="card-body">
                        <h5 class="card-title">' . $satir["kitap_ad"] . '</h5>
                    <a href="profil.php?id=' . $satir["id"] . '"><button type="button" class="btn btn-danger">Kitaba Git</button></a>
                    </div>
                    </div>
                </div>';
        }
        echo "</div>";
        ?>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>

</html>