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;
我正在创建一个日历,将我的数据插入日期,如果我有两个今天的日期任务,那么该任务应该在当天的日历中显示。一切正常,但是当我从数据库中获取数据时,如果我有三行,那么它会重复三次日历循环。