WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : This is now an object, with its interface defined in comments at the beginning of the code. No hooks for graphics yet. I may take some time to do this.
Categories : Date Time, PHP, PHP Classes Update Picture
Peter Norton
Date : Jan 17th 1999
Grade : 2 of 5 (graded 3 times)
Viewed : 6990
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Peter Norton
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php
# This is distributed under the terms of the GNU General Public License.
# Since php3 comes with the license, and I am not in control of the
# distribution of this code, I will refer you to the file COPYING
# that came with PHP. If you can't find it there, go see
# http://www.fsf.org/copyleft/gpl.html
# Copyright 1998 Peter C. Norton <spacey@pobox.com>

class tableCalendar {
# Create an html calendar for a month.
# Interface:
# $calendar = new tableCalendar;
#
# Set necessary variables:
# $calendar->setDay($day); # Integer
# $calendar->setMonth($month); # Integer
# $calendar->setYear($year); # Integer
# $calendar->setFrameTarget($target_string); # String
# $calendar->setHrefString($href_string); # String
#
# $calendar->printCal(); # This'll print your table for you.

var $selectedDay, $selectedMonth, $selectedYear;
var $days;
var $frametarget, $href;
var $DEBUGGING_SET = 0;

function setDay ($day) {
$this->selectedDay = $day;
}
function setMonth ($month) {
$this->selectedMonth = $month;
}
function setYear ($year) {
$this->selectedYear = $year;
}

function setFrameTarget($target_string) {
$this->frametarget = "target = \"$target_string\"";
}

function setHref($href_string) {
$this->href = $href_string;
}

function setAndCheckDefaults () {
if (!$this->selectedDay ) {
$this->selectedDay = date( 'd');
}
if (!$this->selectedMonth) {
$this->selectedMonth = date( 'm');
}
if (!$this->selectedYear) {
$this->selectedYear = date( 'Y');
}

$this->days = array(0=> 'Sun',1=> 'Mon',2=> 'Tue',3=> 'Wed',
4=> 'Thu',5=> 'Fri',6=> 'Sat');
}

function printCal () {
$monthOrig;
$monthTest;
$monthName;
$firstday;
$dayRow;
$lastday = 31;

$this->setAndCheckDefaults(); # make sure we do the right thing(s)

# Find out the first day of the week!
$firstday = date( 'w',mktime(0,0,0,$this->selectedMonth,1,$this->selectedYear));

# have to perform a loop to test from 31 backwards,
# to see what the last day of the month is
$lastday = 31;
do {
$monthOrig = date( 'm',mktime(0,0,0,$this->selectedMonth,1,$this->selectedYear));
$monthTest = date( 'm',mktime(0,0,0,$this->selectedMonth,$lastday,$this->selectedYear));
if ($monthTest != $monthOrig) { $lastday -= 1; };
} while ($monthTest != $monthOrig);

$monthName = date( 'F',mktime(0,0,0,$this->selectedMonth,1,$this->selectedYear));

if($this->DEBUGGING_SET != 0) {
print( "<p>first day of the first week of $selectedMonth $selectedYear is $firstday (from 0 to 6) <p>\n");
print( "The last day of $selectedMonth $selectedYear is $lastday\n<p>");
}

$this->printTable($monthName, $firstday, $lastday);
}

function printHref($day) {
$href = '';

if($this->href) {
print( "<A HREF=\"$this->href?month=$this->selectedMonth&day=$day&year=$this->selectedYear\" $this-
>frametarget>$day</a>");
}
}

function printTable ($monthName, $firstDay, $lastDay) {
$dayRow = 0;
$day = 0;
$targetString;
$adjustedDay;

print( "<table bgcolor=\"#FFFFFF\">");
print( "<caption valign=\"center\"><b>$monthName $this->selectedYear</b></caption>");
print( "<tr>\n");

# Print days along the top.
for($i=0; $i<=6; $i++) {
print( "<td width=10%>".$this->days[$i]. "</td>\n");
}
print( "</tr>\n");

print( "<tr>\n");
while($dayRow < $firstDay) {
print( "<td><!-- This day in prior month --></td>");
$dayRow += 1;
}

while($day < $lastDay) {
if(($dayRow % 7) == 0) {
print( "</tr>\n<tr>\n");
}

$adjustedDay = $day+1;
print( "<td>");
$this->printHref($adjustedDay);
print( "</td>");
$day += 1;
$dayRow += 1;
}
print( "\n</tr>\n</table>\n");
}
}
?>



Validator - A PHP class that can can be used for validating Email IDs and Dates
Categories : PHP, PHP Classes, Data Validation, Email, Date Time
a class that uses microtime() to provide easy calculation of elapsed times
Categories : Date Time, PHP, PHP Classes
A Timing Class
Categories : PHP, PHP Classes, Date Time
Open and Close your website in fixed times .
Categories : PHP, PHP Classes, Cron, Date Time
A time measuring and performance benchmarking class
Categories : PHP, PHP Classes, Testing, Debugging, Date Time
A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function.
Categories : PHP, PHP Classes, Calendar, Date Time
pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes
Example of using the pcCalendar class, article 1468 on weberdev.com. Calendar example.
Categories : PHP, Date Time, PHP Classes, Calendar
Bs_StopWatch is a class to measure time intervals in microseconds.
Categories : PHP, Date Time, PHP Classes
Customizable Calendar Class
Categories : HTML and PHP, Date Time, PHP, PHP Classes, Calendar
ADODB Database Wrapper Abstraction Library for PHP: MySQL, MSSQL, Oracle, Interbase,ODBC, Microsoft Access and FoxPro.
Categories : PHP Classes, Databases, PHP, General SQL, ODBC
Creates three SELECT form fields: Month, Day, and Year. You give it a string which will be used to make the name for the three fields, and a number of seconds to use as the default date. If you give it blank for this value, the current date is used.
Categories : HTML and PHP, PHP, Date Time
This class splits the results of the query into multiple pages like what the search engine does.
Categories : PHP Classes, PHP, MySQL, Databases
Automatic generation of HTML code for a table. OO interface. Can define colspan, rowspan, table style, cell style, and data style. Simple, but effective.
Categories : PHP, PHP Classes, HTML, HTML and PHP
Checks Date-Input from HTML-Forms and converts to YYYY-MM-DD Format for MySQL Date-Fields
Categories : MySQL, Date Time, PHP, Databases