我正在使用以下 jQuery 日历:https ://github.com/MrHus/jquery-monthly-ical/tree/
按照文档,它告诉我应该像这样输入日期:
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 文件显示。在其中,是运行必要变量的所有查询。