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

เขียนเมื่อ 15 ปีก่อน โดย Ninenik Narkdee
php ปฏิทิน calendar css

คำสั่ง การ กำหนด รูปแบบ ตัวอย่าง เทคนิค ลูกเล่น การประยุกต์ การใช้งาน เกี่ยวกับ php ปฏิทิน calendar css

ดูแล้ว 55,141 ครั้ง


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


กด Like หรือ Share เป็นกำลังใจ ให้มีบทความใหม่ๆ เรื่อยๆ น่ะครับ







เนื้อหาที่เกี่ยวข้อง









URL สำหรับอ้างอิง





คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )







เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ