Advertisement
afrizalwahyuadi66

reports.php

Jan 12th, 2025
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include 'db.php';
  4.  
  5. // Pastikan pengguna sudah login dan memiliki peran admin
  6. if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
  7.     header('Location: login.php');
  8.     exit();
  9. }
  10.  
  11. // Mengambil statistik dari database
  12. $student_count_query = "SELECT COUNT(*) AS total_students FROM students";
  13. $class_count_query = "SELECT COUNT(*) AS total_classes FROM classes";
  14.  
  15. $student_count_result = $conn->query($student_count_query);
  16. $class_count_result = $conn->query($class_count_query);
  17.  
  18. $total_students = $student_count_result->fetch_assoc()['total_students'];
  19. $total_classes = $class_count_result->fetch_assoc()['total_classes'];
  20. ?>
  21.  
  22. <!DOCTYPE html>
  23. <html lang="id">
  24. <head>
  25.     <meta charset="UTF-8">
  26.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  27.     <link rel="stylesheet" href="css/style.css">
  28.     <title>Laporan Statistik</title>
  29. </head>
  30. <body>
  31.     <header>
  32.         <h1>Laporan Statistik</h1>
  33.         <nav>
  34.             <a href="dashboard.php">Dashboard</a>
  35.             <a href="logout.php">Logout</a>
  36.         </nav>
  37.     </header>
  38.     <main>
  39.         <h2>Statistik Siswa dan Kelas</h2>
  40.         <div class="report">
  41.             <p><strong>Total Siswa:</strong> <?php echo $total_students; ?></p>
  42.             <p><strong>Total Kelas:</strong> <?php echo $total_classes; ?></p>
  43.         </div>
  44.  
  45.         <h2>Statistik Lainnya</h2>
  46.         <!-- Tambahkan statistik lainnya sesuai kebutuhan -->
  47.     </main>
  48.     <footer>
  49.         <p>&copy; 2023 Arsip Sekolah Dasar</p>
  50.     </footer>
  51. </body>
  52. </html>
Tags: coding
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement