ปฏิทินอย่างง่ายด้วย 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 ได้อย่างง่าย อ่าน 1836 25 Sep 08 การแสดงข้อมูลจากตารางด้วย PHP อ่าน 1831 25 Sep 08 การสร้างวันเวลาปัจจุบัน ด้วยฟังก์ชัน date() อ่าน 1649 25 Sep 08 ใช้ PHP สร้าง Javascript อย่างง่าย อ่าน 1647 14 Feb 09 คำนวณหาอายุ จากวันเกิด ด้วย php อ่าน 1623 31 Mar 09 ดึงข้อมูลจากฐานข้อมูลเป็น excel ด้วย php รองรับภาษาไทย อ่าน 1623 30 Oct 08 ฟังก์ชันตรวจสอบอีเมลล์ ด้วย php ละเอียดมากขึ้น php check verify email อ่าน 1584 25 Sep 08 Upload รูปภาพ หรือไฟล์ด้วย ฟังก์ชั่น ใช้ง่าย อ่าน 1559 10 Nov 08 ฟังก์ชัน PHP ตัดข้อความยาวด้วย wordwrap อ่าน 1522 17 Mar 09 ง่ายๆ กับการส่งค่าตัวแปร PHP ไปใช้ใน Javascript อ่าน 1493 25 Sep 08 Authentication ป้องกันไฟล์ด้วย php อ่าน 1488 04 Nov 08 สร้าง RSS บทความหรือข่าวสาร ด้วย PHP อ่าน 1355 14 Feb 09 ข้อแตกต่างระหว่าง mysql_pconnect กับ mysql_connect อ่าน 1192 03 Nov 08 เก็บ HTML ไว้ในตัวแปร PHP อย่างง่ายด้วยฟังก์ชัน ob_start() อ่าน 1171 15 Feb 09 ดึงข่าว rss มาใช้ในเว็บเราได้อย่างง่ายดายด้วย php อ่าน 1128
จำนวนผู้เยี่ยมชม 85626 คน 2010 © Copyright ninenik.com. All rights reserved.