<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>Program Sistem Pakar Diagnosa</title>
    <link href="assets/css/yeti-bootstrap.min.css" rel="stylesheet"/>
    <link href="assets/css/general.css" rel="stylesheet"/>
    <link href="assets/css/select2.min.css" rel="stylesheet"/>
    <script src="assets/js/jquery.min.js"></script>
    <script src="assets/js/bootstrap.min.js"></script>    
    <script src="assets/js/select2.min.js"></script>   
    <style type="text/css">
      .hi {
        background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('vitaminbg.png');
        background-size: cover;
        background-position: center center;
        background-repeat: no-repeat;
        background-attachment: fixed;
      }
      .dark {
        background-color: #000;
        color: #fff;
      }
      .page-header {
        color: #fff;
      }
      .entry-body {
        padding: 20px;
        max-width: 800px;
        margin: 0 auto;
      }
      .article-title {
        text-align: center;
        margin-bottom: 20px;
      }
      .article-content {
        text-align: justify;
        line-height: 1.6;
        color: #fff;
      }
      .article-date {
        text-align: center;
        margin-top: 20px;
        font-style: italic;
        color: #ccc;
      }
      .back-link {
        display: block;
        text-align: center;
        margin-top: 20px;
        color: #fff;
      }
      .back-link:hover {
        text-decoration: underline;
      }
    </style>
  </head>
  <body class="dark hi">
    <div class="page-header">
      <h1 align='center'>Detail Artikel</h1>
    </div>
    <div class="entry-body">

      <?php
        // Menghubungkan ke database
        include 'config/koneksi.php'; // Pastikan koneksi ke database

        // Mengambil data artikel berdasarkan id
        if (isset($_GET['id_artikel'])) {
            $id_artikel = $_GET['id_artikel'];
            $query = "SELECT judul, konten, tanggal FROM tb_artikel WHERE id_artikel='$id_artikel'";
            $result = $koneksi->query($query);

            // Menampilkan data artikel
            if ($result->num_rows > 0) {
                $row = $result->fetch_assoc();
                $judul = $row['judul'];
                $konten = $row['konten'];
                $tanggal = $row['tanggal'];
                echo '
                  <h2 class="article-title">' . $judul . '</h2>
                  <div class="article-content">' . nl2br($konten) . '</div>
                  <p class="article-date">' . $tanggal . '</p>';
            } else {
                echo '<p>Artikel tidak ditemukan.</p>';
            }
        } else {
            echo '<p>ID artikel tidak ditemukan.</p>';
        }
      ?>

      <a href="?m=artikel" class="back-link">Kembali ke Halaman Artikel</a>
    </div>
  </body>
</html>
