How To Create A Simple Dynamic Calendar Table With PHP

Share:

How To Create A Simple Dynamic Calendar Table With PHP. There is no one who does not know about a calendar. Yes, a calendar can be used to determine how of today’s date and another date within a year. On the website, you can easily display the calendar so that at any time, anyone can see the date through the calendar table on your website.
How To Create A Simple Dynamic Calendar Table With PHPYou want to create an own calendar table for your website and blog ? If your answer is yes, then this tutorial will help you. Come and check out the tutorial below …

In this tutorial we will try to create a calendar table with the help of PHP scripts. This PHP script will create a dynamic calendar table by a full month. If it has been turned into months, it will automatically display the date in the next month ..

Download now How To Create A Simple Dynamic Calendar Table With PHP

How To Create A Simple Dynamic Calendar Table With PHP

Here is a simple PHP script to create a dynamic calendar table on the website :
dynamic-calendar-table.php

<?php
$month= date ("m");
$year=date("Y");
$day=date("d");
$endDate=date("t",mktime(0,0,0,$month,$day,$year));
echo '<font face="arial" size="2">';
echo '<table align="center" border="0" cellpadding=5 cellspacing=5 style=""><tr><td align=center>';
echo "Today : ".date("F, d Y ",mktime(0,0,0,$month,$day,$year));
echo '</td></tr></table>';
echo '<table align="center" border="0" cellpadding=1 cellspacing=1 style="border:1px solid #CCCCCC">
<tr bgcolor="#EFEFEF">
<td align=center><font color=red>Monday</font></td>
<td align=center>Sunday</td>
<td align=center>Tuesday</td>
<td align=center>Wednesday</td>
<td align=center>Thursday</td>
<td align=center>Friday</td>
<td align=center>Saturday</td>
</tr>';
$s=date ("w", mktime (0,0,0,$month,1,$year));
for ($ds=1;$ds<=$s;$ds++) {
echo "<td style=\"font-family:arial;color:#B3D9FF\" align=center valign=middle bgcolor=\"#FFFFFF\">
</td>";}
for ($d=1;$d<=$endDate;$d++) {
if (date("w",mktime (0,0,0,$month,$d,$year)) == 0) { echo "<tr>"; }
$fontColor="#000000";
if (date("D",mktime (0,0,0,$month,$d,$year)) == "Sun") { $fontColor="red"; }
echo "<td style=\"font-family:arial;color:#333333\" align=center valign=middle> <span style=\"color:$fontColor\">$d</span></td>";
if (date("w",mktime (0,0,0,$month,$d,$year)) == 6) { echo "</tr>"; }}
echo '</table>'; 
echo "<p style=\"text-align:center;color:#555;\"><a style=\"text-decoration:none;color:#555;\" href='http://tutorial.world.edu/web-development/how-to-create-simple-dynamic-calendar-table-php/'>PHP Calendar Table</a> by <a style=\"text-decoration:none;color:#555;\" href='http://tutorial.world.edu'>Tutorial.World.Edu</a></p>";?>

Please try to upload to the web hosting server or localhost, and then open it in a web browser. The result will be as below …
How To Create A Simple Dynamic Calendar Table With PHP
If you want the look of the table form a more beautiful and impressive, you can use the css code to beautify the dynamic calendar table. Tutorial about this can be read in How To Create A Simple Flat Calendar Table Using CSS And HTML

Please try this tutorial, and if successful then you can share in your website or blog. Good luck
Thanks for reading How To Create A Simple Dynamic Calendar Table With PHP

[Tutorial.World.Edu]

One thought on “How To Create A Simple Dynamic Calendar Table With PHP

Leave a Reply

Your email address will not be published. Required fields are marked *