<?php
$mysubjects = 0;
$myexams = 0;
$mydepartments = 0;
$notice = 0;
$classes = 0;
$students = 0;

try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname;charset=utf8mb4;collation=utf8_general_ci;prefix=''", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);


$stmt = $conn->prepare("SELECT * FROM tbl_subjects");
$stmt->execute();
$result = $stmt->fetchAll();
$mysubjects = count($result);

$stmt = $conn->prepare("SELECT * FROM tbl_exams");
$stmt->execute();
$result = $stmt->fetchAll();
$myexams = count($result);

$stmt = $conn->prepare("SELECT * FROM tbl_departments");
$stmt->execute();
$result = $stmt->fetchAll();
$mydepartments = count($result);

$stmt = $conn->prepare("SELECT * FROM tbl_notice");
$stmt->execute();
$result = $stmt->fetchAll();
$notice = count($result);

$stmt = $conn->prepare("SELECT * FROM tbl_classes");
$stmt->execute();
$result = $stmt->fetchAll();
$classes = count($result);

$stmt = $conn->prepare("SELECT * FROM tbl_students");
$stmt->execute();
$result = $stmt->fetchAll();
$students = count($result);

}catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}

?>
