<?php include("_ayarlar.php"); ?>
<?php include("_fonksiyonlar.php"); ?>
<?php include("_header.php"); ?>
	    <!-- Start retroy layout blog posts -->
        <section class="section bg-light">
        <div class="container">
        <div id="carouselExampleDark" class="carousel carousel-dark slide">
            <div class="carousel-indicators">

                <?php

                    for ($i=0; $i<5 ; $i++) { 
                        if($i==0) echo "<button type='button' data-bs-target='#carouselExampleDark' data-bs-slide-to='$i' class='active' aria-current='true' aria-label='Slide ".($i+1)."'></button>";
                        else echo "<button type='button' data-bs-target='#carouselExampleDark' data-bs-slide-to='$i' aria-label='Slide ".($i+1)."'></button>";
                    }

                ?>

            </div>
            <div class="carousel-inner">            
                <?php
                $kontrol = 0;
                $sql = "SELECT * FROM haber ORDER BY id DESC LIMIT 5";
                $tablo = $vt->query($sql);
                while($satir = $tablo->fetch_assoc()){
                    if ($kontrol == 0) {
                        echo "<div class='carousel-item active' data-bs-interval='3000'>";
                    } else {
                        echo "<div class='carousel-item' data-bs-interval='3000'>";
                    }
                    echo '<a href="haber.php?id='.$satir['id'].'&baslik='.baslik_donustur($satir['baslik']).'">
                        <img src="kapak/'.$satir['kapak'].'" class="d-block w-100" style="height: 400px; object-fit: cover;" alt="...">
                        <div class="carousel-caption d-none d-md-block">
                            <h5 style="background-color:white">'.$satir['baslik'].'</h5>
                        </div>
                        </a>
                    </div>';  
                    $kontrol++;                  
                }
                ?>
            </div>
            <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleDark" data-bs-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="visually-hidden">Previous</span>
            </button>
            <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleDark" data-bs-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="visually-hidden">Next</span>
            </button>
            </div>
        </div>
    </section>
    <!-- End retroy layout blog posts -->

    <!-- Start posts-entry -->
    <section class="section">
        <div class="container">
            <div class="row">
                <?php
                $sql = "SELECT * FROM haber INNER JOIN kategori ON haber.kategori = kategori.kategori_id ORDER BY id DESC LIMIT 5,9";
                $tablo = $vt->query($sql);
                while($satir = $tablo->fetch_assoc()){ # Haber tablosunda kayıt olduğu sürece
                ?>
                <div class="col-lg-4 mb-4">
                    <div class="post-entry-alt">
                        <a href="haber.php?id=<?php echo $satir['id'] ?>&baslik=<?php echo baslik_donustur($satir['baslik']) ?>" class="img-link"><img src="kapak/<?php echo $satir['kapak'] ?>" alt="Image"
                            class="img-fluid rounded" style="background-size: cover; height: 300px; object-fit: cover;"></a>
                        <div class="excerpt">
                            <h2><a href="haber.php?id=<?php echo $satir['id'] ?>&baslik=<?php echo baslik_donustur($satir['baslik']) ?>"><?php echo $satir['baslik'] ?></a></h2>
                            <div class="post-meta align-items-center text-left clearfix">
                                <span class="d-inline-block mt-1"><?php echo "<a href='kategori.php?id=$satir[kategori]&baslik=".baslik_donustur($satir['kategori_ad'])."'>".$satir['kategori_ad']."</a>" ?></span>
                                <span>&nbsp;-&nbsp; <?php echo tarih_donustur($satir['eklenme_tarihi']) ?></span>
                            </div>
                            <?php echo implode(' ', array_slice(explode(' ', $satir['icerik']), 0, 20)) ?>...
                            <p><a href="haber.php?id=<?php echo $satir['id'] ?>&baslik=<?php echo baslik_donustur($satir['baslik']) ?>" class="read-more">Okumaya Devam Et</a></p>
                        </div>
                    </div>
                </div>
                <?php
                }
                ?>
            </div>

        </div>
    </section>
<?php include("_footer.php"); ?>