<?php

require_once "config.php";

header('Content-Type: application/json');

$method = $_SERVER['REQUEST_METHOD'];

// Menjalankan aksi berdasarkan metode HTTP
switch ($method) {
    case 'GET':
        $cemail = $_GET["cemail"];
        
        $query = $conn->query("SELECT COUNT(*) AS count FROM tbnotif WHERE cemail = '$cemail' AND lstatus = '0'");
        // $result = $query->fetch_all(MYSQLI_ASSOC); // Mengambil semua baris hasil kueri sebagai array asosiatif
        $result = $query->fetch_assoc();
        echo json_encode($result);
        
        break;
}

// Menutup koneksi database
mysqli_close($conn);
?>
