0
for($list_day = 1; $list_day <= $days_in_month; $list_day++):
        $query = mysql_query("SELECT * FROM task_master WHERE TASK_MASTER_SCHEDULE_DATE >='".$first_day_this_month."' AND TASK_MASTER_SCHEDULE_DATE <='".$last_day_this_month."' AND TASK_MASTER_UM_ID=5");
    while($row = mysql_fetch_array($query))
    {
        $sdate = date('j',strtotime($row['TASK_MASTER_SCHEDULE_DATE']));
        $taskdtl = substr($row['TASK_MASTER_ASSIGN_TASK_DTL'], 0, 5);
        $taskhr = $row['TASK_MASTER_HOURS'];
        if($sdate==$list_day)
        {
            if($taskhr >= '8')
            {
                $calendar.= '<td class="calendar-day" style="background-color:green;">';
            }
            else
            {
                $calendar.= '<td class="calendar-day" style="background-color:red;">';
            }
            $calendar .= $taskdtl;
            /* add in the day number */
            $calendar.= '<div class="day-number">'.$list_day.'</div>';

            /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !!  IF MATCHES FOUND, PRINT THEM !! **/
            $calendar.= str_repeat('<p> </p>',2);

            $calendar.= '</td>';
        }
        else
        {
            $calendar.= '<td class="calendar-day">';
            /* add in the day number */
            $calendar.= '<div class="day-number">'.$list_day.'</div>';

            /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !!  IF MATCHES FOUND, PRINT THEM !! **/
            $calendar.= str_repeat('<p> </p>',2);

            $calendar.= '</td>';
        }
        if($running_day == 6):
            $calendar.= '</tr>';
            if(($day_counter+1) != $days_in_month):
                $calendar.= '<tr class="calendar-row">';
            endif;
            $running_day = -1;
            $days_in_this_week = 0;
        endif;
        $days_in_this_week++; $running_day++; $day_counter++;
    }
endfor;

I am creating a calendar with insert my data into dates, if I have two task of today's date then that task should show in that day in calendar. Everything is working fine but when i am fetching data from database and if I have three rows then it repeats calendar loop three times.

1 Answer 1

2

Try to add Continue; in the end of your else condition.

Continue PHP

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

1 Comment

Than try to add a condition before your while loop to count the results if there is no results then execute the else condition, so try to add your else condition outside of the while loop maybe this will work for you :)

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.