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