<?php

function getTeacherCount($con, $orgRefCode) {

    // Prepare the SQL query

    $query = "SELECT * FROM users WHERE admin_ref = '$_SESSION[uref_code]' AND udisplay != 'disable' AND utype = ?";

    

    // Initialize the prepared statement

    if ($stmt = mysqli_prepare($con, $query)) {

        // Bind the parameters

        mysqli_stmt_bind_param($stmt, "s", $orgRefCode);



        // Execute the prepared statement

        mysqli_stmt_execute($stmt);



        // Store the result

        mysqli_stmt_store_result($stmt);



        // Get the number of rows

        $teacherCount = mysqli_stmt_num_rows($stmt);



        // Close the statement

        mysqli_stmt_close($stmt);



        // Return the count

        return $teacherCount;

    } else {

        // If the statement couldn't be prepared, return 0 or handle the error as needed

        return 0;

    }

}

?>

<?php

function getStudentCount($con, $orgRefCode) {

    // Prepare the SQL query

    $query = "SELECT * FROM users WHERE admin_ref = '$_SESSION[uref_code]' AND udisplay != 'disable' AND utype = ?";

    

    // Initialize the prepared statement

    if ($stmt = mysqli_prepare($con, $query)) {

        // Bind the parameters

        mysqli_stmt_bind_param($stmt, "s", $orgRefCode);



        // Execute the prepared statement

        mysqli_stmt_execute($stmt);



        // Store the result

        mysqli_stmt_store_result($stmt);



        // Get the number of rows

        $studentCount = mysqli_stmt_num_rows($stmt);



        // Close the statement

        mysqli_stmt_close($stmt);



        // Return the count

        return $studentCount;

    } else {

        // If the statement couldn't be prepared, return 0 or handle the error as needed

        return 0;

    }

}

?>

<?php

function getClassCount($con, $orgRefCode) {

    // Prepare the SQL query

    $query = "SELECT * FROM class WHERE cdisplay != 'disable' AND uploadedby = ?";

    

    // Initialize the prepared statement

    if ($stmt = mysqli_prepare($con, $query)) {

        // Bind the parameters

        mysqli_stmt_bind_param($stmt, "s", $orgRefCode);



        // Execute the prepared statement

        mysqli_stmt_execute($stmt);



        // Store the result

        mysqli_stmt_store_result($stmt);



        // Get the number of rows

        $classCount = mysqli_stmt_num_rows($stmt);



        // Close the statement

        mysqli_stmt_close($stmt);



        // Return the count

        return $classCount;

    } else {

        // If the statement couldn't be prepared, return 0 or handle the error as needed

        return 0;

    }

}

?>

<?php

function getSubjectCount($con, $orgRefCode) {

    // Prepare the SQL query

    $query = "SELECT * FROM subject WHERE sdisplay != 'disable' AND uploadedby = ?";

    

    // Initialize the prepared statement

    if ($stmt = mysqli_prepare($con, $query)) {

        // Bind the parameters

        mysqli_stmt_bind_param($stmt, "s", $orgRefCode);



        // Execute the prepared statement

        mysqli_stmt_execute($stmt);



        // Store the result

        mysqli_stmt_store_result($stmt);



        // Get the number of rows

        $subjectCount = mysqli_stmt_num_rows($stmt);



        // Close the statement

        mysqli_stmt_close($stmt);



        // Return the count

        return $subjectCount;

    } else {

        // If the statement couldn't be prepared, return 0 or handle the error as needed

        return 0;

    }

}

?>

<?php



function showClassSubjectFromSid($con,$subjectID)

{

   $sql = "SELECT s.cs_id,s.cs_name,c.sclass FROM class_subject AS s INNER JOIN class AS c ON s.cs_class = c.sid WHERE s.cs_id ='$subjectID'";

    $run = mysqli_query($con, $sql);

    $rows = mysqli_fetch_assoc($run);

    $showCS = array(

      "showClass"=>"$rows[sclass]", 

      "showSubject"=>"$rows[cs_name]"

    );

    return  $showCS;

}



function showClass($con,$classID)

{

  $cf_sql = "SELECT sid,sclass FROM class WHERE sid='$classID'";

  $cf_run = mysqli_query($con, $cf_sql);

  $cf_rows = mysqli_fetch_assoc($cf_run);

  return $cf_rows["sclass"];

}



function showFullDate($dt) 

  {

    $date=date_create();

    date_timestamp_set($date,

    strtotime("$dt"));

    return date_format($date,"M j, Y");

  }



function showTime($t) 

  {

    $time=date_create();

    date_timestamp_set($time,

    strtotime("$t"));

    return date_format($time,"g:i a");

  }



?>