私のサイトでは、イベントでカレンダーを作成しました。今月は問題なく動作します。しかし、ページを更新せずに前月と来月をイベントにリンクする方法について混乱しています。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>