Currently have hit a mental wall in my project. Brief summary. We have a table for completed courses on our site. Courses can be put in a plan. Trying to build a CSV export report that will show incompletions/completions so a manager can see progress for their environment and thus get with the employee to finish the plan.
Reports Table:
ID|UID|CID|Completed Date|
1 | 1 |78 |09-14-2021
2 | 1 |79 |09-14-2021
3 | 1 |75 |09-14-2021
4 | 1 |76 |09-14-2021
5 | 1 |77 |09-14-2021
Course table:
ID|NAME | credits | some other info
78|test
79|test2
75|test3
76|test4
77|test5
80|test6
Plan Table:
ID| Courses
8 | 75,76,77,78,79,80
I have the report generating all completions accurately my issue is when it doesn't exist in the completed table since the user hasn't finished it.
I use an if(isset reports.id) to dump info and an else statement to change the date to "incomplete"
My issue is populating the name for that course on the report. I'm not sure of how to check against data that doesn't exist. So in this example the course array would be [78,79,75,76,77,80] but the reports table only has completions for 75,76,77,78,79. The else statement is dumping $x[0] which the first result is "test". So I know my logic is wrong. But for the life of me can't think of the correct way to get the right information.
I need the else state ment to dump the remaining courses that aren't represented in the reports table as they are not complete. Any ideas?
Query for $courses array
"SELECT id, name, credits FROM `courses` WHERE id IN (78,79,75,76,77,80) ORDER BY id")
$courses[] = array($course_data['course_name'], $course_data['credits'],$course_data['id']);
//$exportdata is my SQL pull for all info.
if (isset($exportdata['reports.id'])) {
$completeddate = $exportdata['completed_date'];
$credit = $exportdata['credits'];
$coursename = $exportdata['course_name'];
} else {
foreach ($courses as $x) {
$credit = "-";
$completeddate = 'Incomplete';
$coursename = $x[0];
}
}
Excel function dumps $name, $email, $coursename, $completeddate, $credits in a row.