<?php include("_ayarlar.php"); ?>
<?php include("_fonksiyonlar.php"); ?>
<?php include("_header.php"); ?>

<section class="section">
    <div class="container">

      <div class="row blog-entries element-animate">

        <div class="col-md-12 col-lg-8 main-content">

        <?php 

            $id = $_GET['id'];
            $sql = "SELECT * FROM haber INNER JOIN kategori ON haber.kategori = kategori.kategori_id WHERE id = '$id' ";
            $tablo = $vt->query($sql);
            $satir = $tablo->fetch_assoc();
            $kategori_id = $satir["kategori_id"];
        ?>

          <div class="post-entry">
            <h1 class="mb-4"><?php echo $satir['baslik'] ?></h1>
            <div class="post-meta align-items-center">
              <span class="d-inline-block mt-1">Kategori: <?php echo $satir['kategori_ad'] ?></span>
              <span>&nbsp;-&nbsp; <?php echo tarih_donustur($satir['eklenme_tarihi']) ?></span>
            </div>
          </div>

          <div class="post-content-body">
            <img class="img-fluid w-100 mb-4" src='kapak/<?php echo $satir["kapak"] ?>' />
            <?php echo $satir['icerik'] ?>
          </div>

          <div class="pt-5 comment-wrap">
            <h3 class="mb-5 heading">2 Comments</h3>

            <div class="comment-body">
              <h4>Jean Doe</h4>
              <h6>December 9, 2023 at 18.00</h6>
              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Pariatur quidem laborum necessitatibus, ipsam impedit vitae autem, eum officia, fugiat saepe enim sapiente iste iure! Quam voluptas earum impedit necessitatibus, nihil?</p>
            </div>

            <div class="comment-body">
              <h4>Jean Doe</h4>
              <h6>December 9, 2023 at 21.00</h6>
              <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Pariatur quidem laborum necessitatibus, ipsam impedit vitae autem, eum officia, fugiat saepe enim sapiente iste iure! Quam voluptas earum impedit necessitatibus, nihil?</p>
            </div>
            <!-- END comment-list -->

            <div class="comment-form-wrap pt-5">
              <h3 class="mb-5">Leave a comment</h3>
              <form action="#" class="p-5 bg-light">

                <div class="form-group">
                  <label for="message">Message</label>
                  <textarea name="" id="message" cols="30" rows="10" class="form-control"></textarea>
                </div>
                <div class="form-group">
                  <input type="submit" value="Post Comment" class="btn btn-primary">
                </div>

              </form>
            </div>
          </div>

        </div>

        <!-- END main-content -->

        <div class="col-md-12 col-lg-4 sidebar">
          <div class="sidebar-box">
            <h3 class="heading">İlginizi Çekebilir</h3>
            <div class="post-entry-sidebar">
              <ul>
                <?php
                $sql = "SELECT * FROM haber WHERE id != '$id' AND kategori = '$kategori_id' ORDER BY RAND() LIMIT 3";
                $tablo = $vt->query($sql);
                while($satir = $tablo->fetch_assoc()){
                echo "<li>
                  <a href='haber.php?id=$satir[id]&baslik=deneme'>
                    <img src='kapak/$satir[kapak]' alt='Image placeholder' class='me-4 rounded'>
                    <div class='text'>
                      <h4>$satir[baslik]</h4>
                      <div class='post-meta'>
                        <span class='mr-2'>".tarih_donustur($satir['eklenme_tarihi'])."</span>
                      </div>
                    </div>
                  </a>
                </li>";}
                ?>              
              </ul>
            </div>
          </div>
          <!-- END sidebar-box -->

          <div class="sidebar-box">
            <h3 class="heading">Kategoriler</h3>
            <ul class="categories">
              <?php
                $sql = "SELECT * FROM kategori";
                $tablo = $vt->query($sql);
                while($satir=$tablo->fetch_array()){
                    echo '<li><a href="kategori.php?id='.$satir["kategori_id"].'&baslik='.baslik_donustur($satir["kategori_ad"]).'">'.$satir["kategori_ad"].'<span>('.kategorik_haber_sayisi($satir["kategori_id"]).')</span></a></li>';
                }
              ?>
            </ul>
          </div>
          <!-- END sidebar-box -->

        </div>
        <!-- END sidebar -->

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