Submissions.php: simplify code logic.

Bug430-Eden2
Lan Hui 2023-08-25 21:56:41 +08:00
parent 24af391961
commit 6200d6ab00
1 changed files with 10 additions and 31 deletions

View File

@ -61,45 +61,24 @@ echo "<div><a href='Courses.php?course=$url'> $header </a></div>";
}
$resultx1 = mysqli_query($con, "Select Count(*) as cnt from lab_report_submissions where lab_report_submissions.Lab_Report_ID=$id");
while ($row = mysqli_fetch_assoc($resultx1)) {
$count_subs = $row['cnt'];
}
$row = mysqli_fetch_assoc($resultx1);
$count_subs = $row['cnt'];
$resultx2 = mysqli_query($con, "Select COUNT(*) as cnt from lab_report_submissions where lab_report_submissions.Lab_Report_ID=$id and Status='Marked'");
if (mysqli_num_rows($resultx2) == 0) {
$count_marked = 0;
} else {
while ($row = mysqli_fetch_assoc($resultx2)) {
$count_marked = $row['cnt'];
}
}
$row = mysqli_fetch_assoc($resultx2);
$count_marked = $row['cnt'];
$resultx3 = mysqli_query($con, "Select COUNT(*) as cnt from lab_report_submissions where lab_report_submissions.Lab_Report_ID=$id and Status='Pending'");
if (mysqli_num_rows($resultx3) == 0) {
$count_unmarked = 0;
} else {
while ($row = mysqli_fetch_assoc($resultx3)) {
$count_unmarked = $row['cnt'];
}
}
$row = mysqli_fetch_assoc($resultx3);
$count_unmarked = $row['cnt'];
$resultx4 = mysqli_query($con, "Select COUNT(*) as cnt from lab_report_submissions where lab_report_submissions.Lab_Report_ID=$id and Status='Remarking'");
if (mysqli_num_rows($resultx4) == 0) {
$count_remark = 0;
} else {
while ($row = mysqli_fetch_assoc($resultx4)) {
$count_remark = $row['cnt'];
}
}
$row = mysqli_fetch_assoc($resultx4);
$count_remark = $row['cnt'];
$resultx5 = mysqli_query($con, "SELECT COUNT(*) as cnt FROM course_groups_table WHERE Course_id=$c_id");
if (mysqli_num_rows($resultx5) == 0) {
$count_group = 0;
} else {
while ($row = mysqli_fetch_assoc($resultx5)) {
$count_group = $row['cnt'];
}
}
$row = mysqli_fetch_assoc($resultx5);
$count_group = $row['cnt'];
?>