私はhttp://idea-palette.com/aleventcal/calendar.phpにPHPのカレンダーを持っています。 現在の月の一部ではない日がグレー表示されるようにしたい(これは現在)。前月と翌月の日であるように表示したい。月の合計日数より上の数値を新しい月の日数として表示するにはどうすればよいですか?
今のように、月の最初の日より前に表示される日は、負の数(-1、-2、-3など)とその月の最終日の後に表示される日数として表示されますちょうど続きますので、月が31日に終わると32,33,34などとなります。
私は、それが総日数よりも大きいかどうかを確認して何か他のことを行うことができる何らかのループで条件文を見つけようとしています。
for($i=0; $i< $total_rows; $i++)
{
for($j=0; $j<7;$j++)
{
$day++;
//if the current day is less or equal to the total days in the month
if($day>0 && $day<=$total_days_of_current_month)
{
$date_form = "$current_year/$current_month/$day";
echo '<div class="date_has_event" href="#"><td';
//If the date is today then give the td cell the 'today' class
if($date_form == $today)
{
echo ' class="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>'.$events[$day].'</ul></div>';
}
}
else //if the current day is less or more than the total days in the month
{
//then create a table cell with the current day of the mont
echo '<td class="padding">' . $day . ' </td>'; h
}
}
}
:私が見る問題は、私はちょうどその日+ 1 $の代わりに、32、それだけで33
を読みますか。ここに私のコードですので、もし作成されているテーブルセルは、ループされていることです
これは、1か月の合計日数を超える数値に対してはうまく機能しましたが、月の最初の日より前に来る数値は31,30,29などとする必要がありますが、いくつかの月は30日を持ち、いくつかの月は31日を持っています。 – zeckdude
クリスがどういう問題か分かりません。 http://ca2.php.net/manual/en/function.date.php 't'はその月の日数を表示します。ちょっと考えてみるだけです。すべての難しいものは既にPHPによって与えられています。 – mpen