Bu benim bir online eğitim aldım takvim yazısıdır. Bu çalışıyor ama (Cumartesi sütun sonra) sonuna kadar Pazar sütunu taşımak istiyorum:
<?php
if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");
$month_current = $_REQUEST["month"];
$year_current = $_REQUEST["year"];
$prev_year = $year_current;
$next_year = $year_current;
$month_previous = $month_current-1;
$month_next = $month_current+1;
if ($month_previous == 0 )
{
$month_previous = 12;
$prev_year = $year_current - 1;
}
if ($month_next == 13 )
{
$month_next = 1;
$next_year = $year_current + 1;
}
$timestamp = mktime(0,0,0,$month_current,1,$year_current);
$lastdate = date("t",$timestamp);
$thismonth = getdate ($timestamp);
$firstday = $thismonth['wday'];
?>
<?php
for ($i=0; $i<($lastdate + $firstday); $i++)
{
if(($i % 7) == 0 ) echo "<tr>\n";
if($i < $firstday) echo "<td></td>\n";
else echo "<td align='center' valign='middle' height='20px'>". ($i - $firstday + 1) . "</td>\n";
if(($i % 7) == 6 ) echo "</tr>\n";
}
?>
Ben bu içine kodunu değiştirmek için çalıştı:
<?php
for ($i=0; $i<($lastdate + $firstday); $i++)
{
if(($i % 7) == 1 ) echo "<tr>\n";
# if $i less than the first day (1), don't print the value of $i
if($i < $firstday) echo "<td></td>\n";
# print the value of $i
else echo "<td align='center' valign='middle' height='20px'>". ($i - $firstday + 1) . "</td>\n";
if(($i % 7) == 0 ) echo "</tr>\n";
}
?>
Ilk gün Pazar itibaren başlar İşte o zaman sütununda düzgün görüntülenmez. Örneğin: http://ec-ener.eu/dump/index.php?month=8&year=2010
Bunu nasıl düzeltebilirim? Alternatif olarak, ben sütun sonuna Pazar hareket böylece nasıl özgün senaryoyu değiştirebilirim?
P.S. , Oluşturduğu - tr ve td - Ben de sadece html kontrol eğer orijinal kod biraz sorun / hata var gibi görünüyor öğrendim
<tr>
<td align='center' valign='middle' height='20px'>30</td>
<td align='center' valign='middle' height='20px'>31</td>
</table>
</td>
</tr>
bu kapanış tablo vardır ve tek bir kapatma ancak açıklık yoktur. Ben orijinal tek basit döngü bazı geçersiz html üretir inanıyorum! Ben düzeltebilirim? teşekkürler!