From 6200d6ab007a8e1f8200ca712d1cc69855ba866b Mon Sep 17 00:00:00 2001 From: Lan Hui Date: Fri, 25 Aug 2023 21:56:41 +0800 Subject: [PATCH] Submissions.php: simplify code logic. --- Submissions.php | 41 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/Submissions.php b/Submissions.php index a0a37b1..de6ddfc 100644 --- a/Submissions.php +++ b/Submissions.php @@ -61,45 +61,24 @@ echo "
$header
"; } $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']; ?>