Php > Complete Programs
Simple and fast calendar combining PHP and tables. Use this as a base
Simple and fast calendar combining PHP and tables. Use this as a base for applications in which a calendar is needed /* Set some variables */ $date=01; $day=01; $off=0; /* The month and year variables can (should) be passed from a preceding web page rather than hard coded */ $month = '05'; $year = '1999'; /* Figure out how many days are in this month */ while (checkdate($month,$date,$year)): $date++; endwhile; /* Create a table with days of the week headers */ echo "
"; echo "
Sunday
"; echo "
Monday
"; echo "
Tuesday
"; echo "
Wednesday
"; echo "
Thursday
"; echo "
Friday
"; echo "
Saturday
"; /* Start the table data and make sure the number of days does not exceed the total for the month - $date will always be one more than the total number of days in the momth */ echo "
"; while ($day<$date): /* Figure what day of the week the first falls on and set the number of preceding and trailing cells accordingly */ if ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Sunday') { echo "
$day
"; $off = '01'; } elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Monday') { echo "
$day
"; $off= '02'; } elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Tuesday') { echo "
$day
"; $off= '03'; } elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Wednesday') { echo "
$day
"; $off= '04'; } elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Thursday') { echo "
$day
"; $off= '05'; } elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Friday') { echo "
$day
"; $off= '06'; } elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Saturday') { echo "
$day
"; $off= '07'; } else { echo "
$day
"; } /* Increment the day and increment the cells that go before the end of the row and end the row when appropriate */ $day++; $off++; if ($off>7) { echo "
"; $off='01'; } else { echo ""; } endwhile; echo "
"; ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage