- Step 1
Follow the PHP Calendar Source link in Resources. This will display PHP code. Copy it by highlighting and pressing "Ctrl" + "C."
- Step 2
Open your php file editor to paste the code into a new php file. Be certain that you're saving your file and type php.
- Step 3
Save the file as "calendar.php," but don't close the file. This code won't actually show a calendar just yet, but it's the code the calendar will use.
- Step 4
Go to the bottom of the file and paste the following code before the final ?> (question mark and greater than symbol) at the end of the file.
// Construct a calendar to show the current month
$cal = new Calendar;
echo $cal->getCurrentMonthView(); - Step 5
Test the file by uploading it to your web server with your file upload program. You will see a very simple calendar with the current month displayed and the current date highlighted.
You calendar is created. - Step 1
Add the following CSS style blocks to the beginning of your file before the opening
- Step 2
Change the color of your calendar's header by changing the follow CSS style declaration from Step 1.
calendarHeader {font-weight: bolder; color: #CC0000; background-color: #FFFFCC;}
You can replace the hexadecimal color #FFFFFF for the background with natural name colors like "red," "white," "blue."
You can do the same to replace the hexadecimal colors #CC0000 for the header's text color. - Step 3
Change the color of the current date highlight by changing the follow CSS style declaration from Step 1.
calendarToday {background-color: #FFFFFF;}
Replace the hexadecimal color #FFFFFF for the background with natural name colors or other hexadecimal values. - Step 4
Change the background color of the whole calendar by changing the following CSS style declaration in Step 1.
calendarToday {background-color: #FFFFFF;}
Replace the hexadecimal color #FFFFFF for the background with natural name colors or other hexadecimal values.
If you want to see a broader range of hexadecimal colors, visit the "Hexadecimal Color" link in Resources. - Step 1
Find the following block of code in your calendar.php file (this should be around line 418).
// Construct a calendar to show the current month
$cal = new Calendar;
echo $cal->getCurrentMonthView(); - Step 2
Replace the code with the following code block.
class MyCalendar extends Calendar { function getCalendarLink($month, $year) {
// Redisplay the current page, but with some parameters
// to set the new month and year
$s = getenv('SCRIPT_NAME'); return "$s?month=$month&year=$year"; } } - Step 3
Add the following code block to the end of the calendar.php file after all other code.
$d = getdate(time());
if ($month == "") {
$month = $d["mon"]; }
if ($year == "") {
$year = $d["year"]; }
$cal = new MyCalendar;
echo $cal->getMonthView($month, $year);
?> - Step 4
Test your new customized calendar by uploading calendar.php to your web server. Your calendar will show the current month with date highlighted. You can now navigate through the months.
- Step 1
Open the web page you want to integrate your new calendar into. For this to work, the file in which you want to integrate the calendar must also be a php file.
- Step 2
View the code of your file and paste the following code where you want your new calendar to appear.
include ("calendar.php");
?> - Step 3
Put your calendar.php in the same folder/directory as your web pate that will display the calendar.
About Me
- lakhvinder kulrian
- Kulrian/Bareta, Punjab, India
- I am simple and coool boy.
Thursday, 19 November 2009
How to Create a Calendar Using PHP | eHow.com
A PHP calendar is very easy to set up in just a few minutes. Use the calendar on your website to display the current month and date. You can also scroll through previous and coming months. With a little work you can integrate a calendar into your existing web page.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment