script,displays,calendar,built,table,specifie
Quick Search for:  in language:    
script,displays,calendar,built,table,specifie
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
PHP Stats

 Code: 74,754 lines
 Jobs: 12 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for PHP.
Smart Image Navigator
By Brian Di Croce on 10/27


Click here to see a screenshot of this code!Form security verification
By Christian Mallette on 10/26

(Screen Shot)

Click here to see a screenshot of this code!Guestbook
By Nightmare on 10/25

(Screen Shot)

Shout! Box
By Nightmare on 10/23


SERVER-TO-SERVE R site (or single dir) transfer
By Raffaele Marranzini on 10/22


Site IP Logger - Watch who comes to your site!
By KRaZY-DeSiGN on 10/21


IP Banner - Block unwanted people from your site!
By KRaZY-DeSiGN on 10/20


PWGen
By Flinn Mueller on 10/19


URHere
By Flinn Mueller on 10/19


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Calendar

Print
Email
 
VB icon
Submitted on: 9/25/2002 10:11:51 AM
By: Josh Sherman  
Level: Intermediate
User Rating: By 2 Users
Compatibility:PHP 4.0

Users have accessed this code 736 times.
 

(About the author)
 
     This script displays a calendar (built out of a table) for the specified month and year, and allows you to skip forward and backwards between months. This is a small component of another (larger) project of mine.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    //**************************************
    //     
    // Name: Calendar
    // Description:This script displays a ca
    //     lendar (built out of a table) for the sp
    //     ecified month and year, and allows you t
    //     o skip forward and backwards between mon
    //     ths. This is a small component of anothe
    //     r (larger) project of mine.
    // By: Josh Sherman
    //
    // Inputs:month and year on the Querystr
    //     ing
    //
    // Returns:A calendar for the specified 
    //     month
    //
    // Side Effects:This code might make you
    //     want to be a better person
    //
    //This code is copyrighted and has    // limited warranties.Please see http://
    //     www.Planet-Source-Code.com/xq/ASP/txtCod
    //     eId.752/lngWId.8/qx/vb/scripts/ShowCode.
    //     htm    //for details.    //**************************************
    //     
    
    <?
    /* Print out the HTML headers, and calendar header */
    echo "<HTML>\n"
    . " <HEAD>\n"
    . " <STYLE>\n"
    . "BODY, TD, TH\n"
    . "{\n"
    . " font-family: Verdana;\n"
    . " font-size: 8pt;\n"
    . "}\n"
    . " </style>\n"
    . " </head>\n"
    . " <BODY>\n";
    /* Grab the month and year */
    if ($month == "" || $year == "")
    {
    $this_month = date("n");
    $month_name = date("F");
    $this_year = date("Y");
    }
    else
    {
    $this_month = date("n", mktime(0, 0, 0, $month, 1, $year));
    $month_name = date("F", mktime(0, 0, 0, $month, 1, $year));
    $this_year = date("Y", mktime(0, 0, 0, $month, 1, $year));
    }
    /* This is for the navigation */
    $last_month = $this_month - 1;
    $next_month = $this_month + 1;
    /* Same with all this stuff */
    if ($last_month == 12)
    $last_year = $this_year - 1;
    else
    $last_year = $this_year;
    /* DITTO!!! */
    if ($next_month == 1)
    $next_year = $this_year + 1;
    else
    $next_year = $this_year;
    /* Display the calendar header */
    echo " <CENTER><B>Calendar for $month_name, $this_year</b></center><BR>\n" 
    . " <TABLE align=\"center\" border=\"2\" bordercolor=\"#000000\" cellpadding=\"5\" cellspacing=\"0\">\n"
    . "<TR bgcolor=\"#DDDDDD\">\n"
    . "<TH width=\"50\">Sun</th>\n"
    . "<TH width=\"50\">Mon</th>\n"
    . "<TH width=\"50\">Tue</th>\n"
    . "<TH width=\"50\">Wed</th>\n"
    . "<TH width=\"50\">Thu</th>\n"
    . "<TH width=\"50\">Fri</th>\n"
    . "<TH width=\"50\">Sat</th>\n"
    . "</tr>\n";
    /* Grab the first day of the month, and total days */
    $first_day = date("w", mktime(0, 0, 0, $this_month, 1, $this_year));
    $total_days = date("t", mktime(0, 0, 0, $this_month, 1, $this_year));
    /* Start on the day of the first week */
    $week_num = 1;
    $day_num = 1;
    /* While the day of the week isn't '7' */
    while ($week_num <= 6)
    {
    echo "<TR>\n";
    /* Loop through the week days */
    for ( $i = 0; $i <= 6; $i++ )
    {
    /* If it's the first week then... */
    if ($week_num == 1)
    {
    /* If it's not the first day yet, then use a space */
    if ($i < $first_day)
    $the_day = " ";
    /* If it is the first day, then start with a '1' */
    else if ($i == $first_day)
    {
    $the_day = 1;
    }
    }
    else
    {
    /* If we're past the total days, then use spaces */
    if ($the_day > $total_days)
    $the_day = " ";
    }
    /* Display the day (or space) */
    echo "<TD height=\"50\" width=\"50\" valign=\"top\">$the_day</td>\n";
    /* Incrememnt the day of the month */
    if ($the_day != " ")
    $the_day++;
    }
    echo "</tr>\n";
    /* Increment the week number */
    $week_num++;
    }
    /* Finish off with closing out our tags */
    echo " </table>\n"
    . " <BR>\n"
    . " <CENTER>\n"
    . "<< <A href=\"?month=$last_month&year;=$last_year\">Last Month</a> || <A href=\"?month=$next_month&year;=$next_year\">Next Month</a> >>\n"
    . " </center>\n"
    . " </body>\n"
    . "</html>\n";
    ?>


Other 13 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
10/5/2002 10:56:16 PM:
Hey Josh,
I really like your script 
but I can't seem to run it in my 
browser. Can you please tell me how I 
can get this calender example running? 
Thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/11/2002 12:01:20 AM:
Thast great....
i like to post a 
calendar activities of my 
work...
you have a TEN...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | PHP Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.