0
我使用jQuery的以下日曆日曆:https://github.com/MrHus/jquery-monthly-ical/tree/填充與PHP的foreach代碼
繼文檔,它告訴我,日期應這樣輸入:
eventdates: [{"date": "2009-03-21", "title": "My birthday", "desc": "Its my birthday!"},
{"date": "yyyy-01-01", "title": "New Year", "desc": "Its a new year!"},
{"date": "2009-mm-01", "title": "New Month", "desc": "First day of the new month!"},
{"date": "2010-mm-01", "title": "New Month", "desc": "First day of the new month!"},
{"date": "2010-09-01", "title": "Convention", "desc": "September convention."},
{"date": "2010-09-02", "title": "Convention", "desc": "September convention day two."},
{"date": "2010-mm-01", "title": "Towl", "desc": "Dont forget to bring a towl."}
]
不過,我會喜歡用PHP變量來填充上面的數組,用foreach語句。我這有,但它不工作,沒有錯誤,沒有警告,但不顯示事件:
<?php
foreach($events as $event)
{
?>
eventdates: [{"date": "<?php date('Y/m/d') ?>", "title": "<?php $event->title ?>", "desc": "<a href="<?php echo SITE_URL ?>/index.php/events/get_event?id=<?php $event->id ?>">Details/Signups</a>"},]
<?php
}
?>
這是日曆之外前面的代碼,並在表的內部我別無選擇,它的工作原理:
<?php
if(!$events)
{
echo 'No Upcoming Events';
}
else
{
?>
<center>
<table border="1px" width="80%">
<tr>
<td width="25%"><b>Date:</b></td>
<td width="60%"><b>Event:</b></td>
<td><b>Details/Signups</b></td>
</tr>
<?php
foreach($events as $event)
{
if($event->active == '2')
{
continue;
}
echo '<tr><td>'.date('n/j/Y', strtotime($event->date)).'</td>';
echo '<td>'.$event->title.'</td>';
echo '<td><a href="'.SITE_URL.'/index.php/events/get_event?id='.$event->id.'">Details/Signups</a></td></tr>';
}
?>
</table>
</center>
<?php
}
?>
該代碼位於.tpl文件中,該文件通過.class.php文件顯示。在裏面,是所有查詢運行必要的變量。
它顯示的日曆,但它仍然沒有顯示的事件。 – zzwyb89 2013-02-10 14:49:20
已添加到第一篇文章。 – zzwyb89 2013-02-10 14:52:50
http://pastebin.com/Qc8GByBE。我已經先試過你的建議:''date'=> date('Y/m/d')'然後將它改回我的版本,看它是否會起作用。 – zzwyb89 2013-02-10 15:01:40