0

In my course_status table. I have 3 columns(course_name, course_status, student_id). When I searched for a student id, the course_name cell table should change according to the status. This is the query I am using to get pending, completed and incomplete courses into my arrays.

$done_course = array();
$progress_course = array();
$pending_course = array();
 while($row2 = mysqli_fetch_assoc($retval2)){
        if($row2['course_status'] = 'pending') {
                $pending = True; 
                array_push($pending_course, $row2['course_name']);}
         if($row2['course_status'] = 'In_progress')  {
                $progress = True;                                                 
                 array_push($progress_course,$row2['course_name']); } 
          if($row2['course_status'] = 'done') {
                 $done = True; 
                 array_push($done_course, $row2['course_name']); }

My question is when I run the code $done_courses will store all courses including pending and incomplete. How do I prevent it and make it only store completed courses?

2
  • So what is the question? You need to show us more detail e.g. how you output the cell table, and how you want to change it dependent on the status. Commented Apr 17, 2019 at 2:03
  • @Nick, I use js to output the cell but I just need to fogure how to get the courses into the arrays. Commented Apr 17, 2019 at 2:07

1 Answer 1

1

My question is when I run the code $done_courses will store all courses including pending and incomplete.

I don't think this was printing mistake if($row2['course_status'] = 'pending') { you are comparing with single = instead of ==

Once you change this = to this == it will work fine...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.