我希望我的日历显示来自mysql表的所有事件,但是这段代码只显示了最后一个。这是我的代码:
$result5 = mysqli_query($con,"SELECT * FROM event WHERE username IN ('$matches')");
$num_rows = mysqli_num_rows($result5);
while($row5 = mysqli_fetch_array($result5))
{
$time=strtotime($row5['start_date']);
$day = date("d",$time);
$month= date("m",$time);
$month2= date("F",$time);
$year=date("Y",$time);
echo "$day $month $year ".$row5['name_event'] ; // this show me correct
echo '<br/>';
$calendar = new donatj\SimpleCalendar();
$calendar->addDailyHtml( "Event", "$day-$month-$year");// there is some problem
}
$calendar->show(true);
我使用的函数中有代码:
public function addDailyHtml( $html, $start_date_string, $end_date_string = null ) {
static $htmlCount = 0;
$start_date = strtotime($start_date_string);
if( $end_date_string ) {
$end_date = strtotime($end_date_string);
} else {
$end_date = $start_date;
}
$working_date = $start_date;
do {
$tDate = getdate($working_date);
$working_date += 86400;
$this->daily_html[$tDate['year']][$tDate['mon']][$tDate['mday']][$htmlCount] = $html;
} while( $working_date < $end_date + 1 );
$htmlCount++;
}
有人可以帮助我,为什么日历只显示一个事件?