query($query); // Initialize an array to store the products (courses) $courses = []; if ($result->num_rows > 0) { // Fetch all rows and store them in the $courses array while ($row = $result->fetch_assoc()) { $courses[] = $row; } } else { echo "No products found."; } ?>