对于我的网站,我用 events.it 制作了一个日历。它在本月运行良好。但我对如何在不刷新页面的情况下将上个月和下个月的事件链接起来感到困惑。我想使用ajax,但我不知道。欢迎任何帮助。提前致谢。我的代码:
<h1><?php echo "<strong>".$current_month_text."</strong>";?></h1>
<a href="javascript:;" onclick="newCalender(<?php echo $previous_month;?>)">Previous</a>
<table cellspacing="0">
<thead>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
</tr>
</thead>
<tr>
<?php
for($i=0; $i< $total_rows; $i++)
{
for($j=0; $j<7;$j++)
{
$day++;
if($day>0 && $day<=$total_days_of_current_month)
{
//YYYY-MM-DD date format
$date_form = "$current_year/$current_month/$day";
echo '<td';
//check if the date is today
if($date_form == $today)
{
echo ' id="today"';
}
//check if any event stored for the date
if(array_key_exists($day,$events))
{
//adding the date_has_event class to the <td> and close it
echo ' class="date_has_event"> '.$day;
//adding the eventTitle and eventContent wrapped inside <span> & <li> to <ul>
echo '<div class="events"><ul>';
foreach ($events as $key=>$event){
if ($key == $day){
foreach ($event as $single){
echo '<li>';
echo anchor("events_detail/$single->url",'<span class="title">'.$single->event_title.'</span><span class="desc">'.character_limiter(strip_tags(stripslashes($single->description)),100).'</span>');
echo '</li>';
} // end of for each $event
}
} // end of foreach $events
echo '</ul></div>';
} // end of if(array_key_exists...)
else
{
//if there is not event on that date then just close the <td> tag
echo '> '.$day;
}
echo "</td>";
}
else
{
//showing empty cells in the first and last row
echo '<td class="padding"> </td>';
}
}
echo "</tr><tr>";
}
?>
</tr>
</table>