ARTICLE AD BOX
<?php
//Fetch course data from the database
$sql = "SELECT CourseID, UniversityID, SubjectInterest FROM university_courses";
$result = $connection->query($sql);
$courseCount = 0;
$uniCount = 0;
$currentCourseCount = 1;
$currentUniCount = 1;
if($result->num_rows > 0) {
//Output data of each row
while($row = $result->fetch_assoc()) {
$currentCourseCount = $row["SubjectInterest"];
$currentUniCount = $row["SubjectInterest"];
if($currentCourseCount > $courseCount){
$currentCourseCount = $courseCount;
$courseID = $row["CourseID"];
}
if($currentUniCount > $uniCount){
$currentUniCount = $uniCount;
$uniID = $row["UniversityID"];
}
echo $row["CourseID"];
echo $row["SubjectInterest"];
echo $courseCount;
echo $uniCount;
echo $currentCourseCount;
echo $currentUniCount;
}
}
$connection->close();
?>
The first 2 echos are correct but the remaining 4 output 0 for every row. No subject interest value is 0, they are all at least 1 and many are higher, so the current and overall counts should be values higher than 0.
It is cycling through each row correctly, it just isn't inserting the correct values into the variables.
