PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php session_start(); include('config.php'); if (!isset($_SESSION['user_id'])) { header('Location: login.php'); } $user_department = $_SESSION['department']; // Ambil kategori $category_filter = ''; if (isset($_GET['category'])) { $category_id = $_GET['category']; $category_filter = "AND category_id='$category_id'"; } // Query aplikasi sesuai department user $sql = "SELECT * FROM applications WHERE department='$user_department' $category_filter"; $result = mysqli_query($conn, $sql); // Ambil semua kategori $categories = mysqli_query($conn, "SELECT * FROM categories"); ?> <!DOCTYPE html> <html> <head> <title>Portal Aplikasi</title> <link rel="stylesheet" href="css/bootstrap.min.css"> <style> .app-card { border: 1px solid #ddd; padding: 15px; text-align: center; margin-bottom: 20px; } .app-card img { max-width: 100%; height: 100px; } .app-card:hover .app-description { display: block; } .app-description { display: none; position: absolute; background: #fff; padding: 10px; border: 1px solid #ddd; z-index: 1000; width: 200px; left: 50%; transform: translateX(-50%); top: 110%; } </style> </head> <body> <div class="container"> <h2>Selamat Datang, <?php echo $_SESSION['username']; ?></h2> <a href="logout.php">Logout</a> <!-- Menu Kategori --> <ul class="nav nav-tabs"> <li class="nav-item"><a href="index.php" class="nav-link">Semua</a></li> <?php while($cat = mysqli_fetch_assoc($categories)) { ?> <li class="nav-item"> <a href="index.php?category=<?php echo $cat['id']; ?>" class="nav-link"> <?php echo $cat['name']; ?> </a> </li> <?php } ?> </ul> <!-- Daftar Aplikasi --> <div class="row"> <?php while($app = mysqli_fetch_assoc($result)) { ?> <div class="col-md-3"> <div class="app-card"> <img src="images/<?php echo $app['logo']; ?>" alt="<?php echo $app['name']; ?>"> <h5><?php echo $app['name']; ?></h5> <div class="app-description"> <?php echo $app['description']; ?> </div> </div> </div> <?php } ?> </div> </div> <!-- Script Bootstrap --> <script src="js/bootstrap.min.js"></script> </body> </html>
Show:  
Copy Clear