ปฏิทินอย่างง่ายด้วย php และ css

CSS Code

 <style type="text/css">
#calendar_css {
	background-color:#F0F0F0;
	border-style:solid;
	border-width:0px;
	border-right-width:0px;
	border-bottom-width:0px;
	border-color:#cccccc;
}
#calendar_css td{
	text-align:center;
	font:11px tahoma;
	width:2%;
	height:18px;
}
#calendar_css thead{
	text-align:center;
	font:11px tahoma;
	width:2%;
	height:18px;
	background-color:#333333;
	color:#FFFFFF;
}
#calendar_css .current{
	text-align:center;
	font:11px tahoma;
	width:2%;
	height:18px;
	background-color:#FF0000;
	color:#FFFFFF;
}
col.holidayCol{
	background-color:#FDDFE4;
	color:#FF0000;
}
td.monthTitle{
	background-color:#666666;
	text-align:center;
	font:11px bold tahoma;	
}
 </style>

PHP Code

<?php   
$day_now=array("Sun"=>"1","Mon"=>"2","Tue"=>"3","Wed"=>"4","Thu"=>"5","Fri"=>"6","Sat"=>"7");   
$first_day=date("D",mktime(0,0,1,intval(date("m")),1,date("Y")));   
$start_td=$day_now[$first_day]-1;      
$num_day=date("t");   
$num_day2=($num_day+$start_td);   
$num_day3=(7*ceil($num_day2/7));   
?>   
<table id="calendar_css" width="175" border="0" cellspacing="0" cellpadding="0">   
<colgroup>   
<col class="holidayCol" />   
<col span="5" />   
<col class="holidayCol" />   
</colgroup>   
<thead>   
<tr>
<td colspan="7" class="monthTitle">
<?=date("M-Y")?>
</td>
</tr>
  <tr>   
    <td>อา </td>   
    <td>จ </td>   
    <td>อ </td>   
    <td>พ </td>   
    <td>พฤ </td>   
    <td>ศ </td>   
    <td>ส </td>   
  </tr>   
</thead>   
<?php for($i=1;$i <=$num_day3;$i++){ ?>   
<?php if($i%7==1){ ?>   
  <tr>   
  <?php } ?>   
    <td   <?=(date("j")==$i-$start_td)?"class="current"":""?>> <?=($i-$start_td>=1 && $i-$start_td <=$num_day)?$i-$start_td:" "?> </td>   
<?php if($i%7==0){ ?>   
  </tr>   
  <?php } ?>   
<?php } ?>   
</table>  

ตัวอย่าง

Dec-2009
อา พฤ
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31

บทความในหมวดที่่น่าสนใจ อื่นๆ PHP Learning

25 Oct 08 ส่งอีเมลล์พร้อมกับแนบไฟล์ด้วย php mail function ได้อย่างง่าย อ่าน 1817 25 Sep 08 การแสดงข้อมูลจากตารางด้วย PHP อ่าน 1816 25 Sep 08 การสร้างวันเวลาปัจจุบัน ด้วยฟังก์ชัน date() อ่าน 1639 25 Sep 08 ใช้ PHP สร้าง Javascript อย่างง่าย อ่าน 1632 31 Mar 09 ดึงข้อมูลจากฐานข้อมูลเป็น excel ด้วย php รองรับภาษาไทย อ่าน 1609 14 Feb 09 คำนวณหาอายุ จากวันเกิด ด้วย php อ่าน 1601 30 Oct 08 ฟังก์ชันตรวจสอบอีเมลล์ ด้วย php ละเอียดมากขึ้น php check verify email อ่าน 1572 25 Sep 08 Upload รูปภาพ หรือไฟล์ด้วย ฟังก์ชั่น ใช้ง่าย อ่าน 1529 10 Nov 08 ฟังก์ชัน PHP ตัดข้อความยาวด้วย wordwrap อ่าน 1507 17 Mar 09 ง่ายๆ กับการส่งค่าตัวแปร PHP ไปใช้ใน Javascript อ่าน 1475 25 Sep 08 Authentication ป้องกันไฟล์ด้วย php อ่าน 1474 04 Nov 08 สร้าง RSS บทความหรือข่าวสาร ด้วย PHP อ่าน 1344 14 Feb 09 ข้อแตกต่างระหว่าง mysql_pconnect กับ mysql_connect อ่าน 1177 03 Nov 08 เก็บ HTML ไว้ในตัวแปร PHP อย่างง่ายด้วยฟังก์ชัน ob_start() อ่าน 1160 15 Feb 09 ดึงข่าว rss มาใช้ในเว็บเราได้อย่างง่ายดายด้วย php อ่าน 1119
จำนวนผู้เยี่ยมชม 84563 คน 2010 © Copyright ninenik.com. All rights reserved.