query
// ("SELECT user_id AS 'ID', username AS 'Username', SUBSTRING(password, 1, 20) AS 'Password', IFNULL(school_name,'Not Applicable') AS 'School', IFNULL(specific_classCode,'Not Applicable') AS 'Class',active AS 'Active'
// FROM user_account
// inner join user_role on user_account.accountType = user_role.role_id
// left join school on user_account.school_id = school.school_id
// left join school_class on user_account.class_id = school_class.class_id
// WHERE accountType = 2
// ORDER BY user_id ASC");
// }
// else{
// $result = $conn->query
// ("SELECT user_id AS 'ID', username AS 'Username', SUBSTRING(password, 1, 20) AS 'Password', IFNULL(school_name,'Not Applicable') AS 'School', IFNULL(specific_classCode,'Not Applicable') AS 'Class',active AS 'Active'
// FROM user_account
// inner join user_role on user_account.accountType = user_role.role_id
// left join school on user_account.school_id = school.school_id
// left join school_class on user_account.class_id = school_class.class_id
// Where accountType = 2
// AND user_account.school_id = $schoolID
// ORDER BY user_id ASC");
// }
$userAccount = $conn->query("SELECT accountType, school_id FROM user_account WHERE username = '".$_SESSION['user']. "'");
$row = $userAccount->fetch_assoc();
$userAccountType = $row['accountType'];
$schoolID = $row['school_id'];
//echo $schoolID;
$userRole = $conn->query("SELECT role FROM user_role WHERE role_id = ".$userAccountType);
//echo $userAccountType;
// while ($row = $userAccount->fetch_assoc()) {
// echo $row['accountType']."
";
// }
// echo $_SESSION['user'];
if($userAccountType == 5){
$result = $conn->query
("SELECT user_id AS 'ID', username AS 'Username', email AS 'Email', password AS 'Password', IFNULL(school_name,'Not Applicable') AS 'School',active AS 'Active'
FROM user_account
inner join user_role on user_account.accountType = user_role.role_id
left join school on user_account.school_id = school.school_id
left join school_class on user_account.class_id = school_class.class_id
WHERE accountType = 2
ORDER BY user_id ASC");
}
else{
$result = $conn->query
("SELECT user_id AS 'ID', username AS 'Username', email AS 'Email', password AS 'Password', IFNULL(school_name,'Not Applicable') AS 'School',active AS 'Active'
FROM user_account
inner join user_role on user_account.accountType = user_role.role_id
left join school on user_account.school_id = school.school_id
left join school_class on user_account.class_id = school_class.class_id
Where accountType = 2
AND user_account.school_id = $schoolID
ORDER BY user_id ASC");
}
$tablesAndTheirData = array();
array_push($tablesAndTheirData, array(
'fields' => $result->fetch_fields(),
'data' => $result
));
foreach($tablesAndTheirData as $table){
if($table['data']->num_rows){
?>