WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
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 Index
Web Development Resources
Web Development Content
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
Mobile Dev World

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 : CALENDAR - easy calendar-navigation with PHP
Categories : PHP, Date Time, HTML and PHP, Calendar Update Picture
Gernot Brandl
Date : Feb 14th 2001
Grade : 2 of 5 (graded 16 times)
Viewed : 27500
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Gernot Brandl
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<html>
<head>
<title>Rocket Organizer</title>
<link rel=stylesheet type="text/css" href="./styles/styles.css">
</head>
<body bgcolor="#FFFFE0">
<?php

$j = $j ? $j : date("Y",time());
$m = $m ? $m : date("n",time());
$d = $d ? $d : date("j",time());
$intDATE=(mktime(0,0,0,$m,$d,$j));
$upM=mktime(0,0,0,($m+1),1,$j);
$doM=mktime(0,0,0,($m-1),1,$j);

function get_mARRAY() {
        global $intDATE;
        global $d;
        global $m;
        global $j;
        if (date("w",mktime(0,0,0,$m,1,$j))==2) { //if 1st of requested month is a monday -
start with first
        $startDAY=mktime(0,0,0,$m,1,$j);
        } else {                                //if not then we look for the last monday of
the previous month
        $startDAY=mktime(0,0,0,$m,0-date("w",mktime(0,0,0,$m,1-1,$j)),$j);
        }

        for ($i=1;$i<=42;$i++) {

        $marray[$i]=mktime(0,0,0,date("n",$startDAY),date("j",$startDAY)+$i,date
("Y",$startDAY));
        }
return $marray;
}
$mARRAY=get_mARRAY();
?>
<table border="0">
        <tr>
                <td align="left">
                        <?php
                                echo '<a href="calnav.php?j=' . date
("Y",$doM) . '&m=' . date("n",$doM) . '&d=' . date("j",$doM) . '" target="navframe">';
                                echo '<img src="./images/mondo.gif" border=0>';
                                echo '</a>';
                        ?>
                        </td>
        <td colspan="5">
                        <p align="center"><font size="1"
                face="Verdana" color="#000080">
                        <?php
                        echo date("F",$intDATE) . " " . date("Y",$intDATE);
                        ?></font></p>
                 </td>
         <td align="right">
                        <?php
echo '<a href="calnav.php?j=' . date("Y",$upM) . '&m=' . date
("n",$upM) . '&d=' . date("j",$upM) . '" target="navframe">';
echo '<img src="./images/monup.gif" border=0>';
echo '</a>';
?>
                </font> </td>

        </tr>
        <tr>
                <td width=17 height=17 align="center" bgcolor="#000080">
                <font color="#FFFFFF">
                M
                </font></td>
                <td width=17 height=17 align="center" bgcolor="#000080">
<font color="#FFFFFF">
T
</font></td>
                <td width=17 height=17 align="center" bgcolor="#000080">
<font color="#FFFFFF">
W
</font></td>
                <td width=17 height=17 align="center" bgcolor="#000080">
<font color="#FFFFFF">
T
</font></td>
                <td width=17 height=17 align="center" bgcolor="#000080">
<font color="#FFFFFF">
F
</font></td>
                <td width=17 height=17 align="center" bgcolor="#000080">
<font color="#FFFFFF">
S
</font></td>
                <td width=17 height=17 align="center" bgcolor="#000080">
<font color="#FFFFFF">
S
</font></td>
        </tr>

<?php
        $countDAYS=1;
        for ($w=1;$w<=6;$w++) {
        echo '<tr>';
                for ($d=1;$d<=7;$d++) {
                        echo '<td height=15 align="center">';
                        if (((date("j",$mARRAY[$countDAYS])>7) & ($w==1)) | ((date
("j",$mARRAY[$countDAYS])<=14) & ($w>=5))) {

        echo '<a href="calnav.php?j=' . date("Y",$mARRAY[$countDAYS]) . '&m=' .
date("n",$mARRAY[$countDAYS]) . '&d=' . date("j",$mARRAY[$countDAYS]) . '"
target="navframe" style="color:C0C0C0">';
        echo date("j",$mARRAY[$countDAYS]);
        echo '</a>';
                        } else {
                                if ($mARRAY[$countDAYS]==$intDATE) {
        echo '<strong>';
        }

        echo '<a href="calnav.php?j=' . date("Y",$mARRAY[$countDAYS]) . '&m=' .
date("n",$mARRAY[$countDAYS]) . '&d=' . date("j",$mARRAY[$countDAYS]) . '"
target="navframe">';
        echo date("j",$mARRAY[$countDAYS]);
        echo '</a>';
        if ($mARRAY[$countDAYS]==$intDATE) {
        echo '</strong>';
        }        
                        }        



                        echo '</td>';
                $countDAYS=++$countDAYS;
                }
        echo '</tr>';        
        }
?>
</table>
</body>
</html>



Customizable Calendar Class
Categories : HTML and PHP, Date Time, PHP, PHP Classes, Calendar
This script contains 2 functions: 1 to create html select object based on your own customer date format entry- "M d Y h:i.... etc". The second function processes the select object on submit back to unix time.
Categories : PHP, Calendar, Date Time, HTML and PHP
Calendar using Date function
Categories : HTML and PHP, PHP, Date Time, Calendar
Simple PHP control CSS Calendar
Categories : PHP, HTML and PHP, Calendar, Date Time, CSS
function to generate calendars on the fly.
Categories : Calendar, PHP, Date Time
Calendars to choose a range of dates , reservation events ...
Categories : PHP, Calendar, Java Script, Date Time
PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
Monthly and Daily Upcoming Events calendar.
Categories : Date Time, PostgreSQL, PHP, Calendar, Databases
PHP Calendar Web App
Categories : PHP, Databases, MySQL, Date Time, Calendar
Functions used to define a schedule of holidays. Can define non-fixed holidays (eg. 3rd sunday of June).
Categories : Calendar, Date Time, PHP
Website colour changer
Categories : PHP, HTML and PHP, Date Time
PHP Calendar
Categories : PHP, Calendar, Date Time, Java Script, CSS
Select with current month
Categories : PHP, HTML and PHP, Date Time, Arrays
A simple and fast calendar combining PHP and tables. Use this as a base for applications in which a calendar is needed.
Categories : Date Time, PHP, Complete Programs, Calendar
Calendar, Kalender, date, time, day, month, year
Categories : PHP, Date Time, Calendar
 uhhh uhhh wrote : 575
for each of the scripts posted you should have an active link to a site which is using that script!

just a thought
chris&lt;pixelmonkey&gt;
 
 Gernot Brandl wrote : 576
sorry, but this script runs only on a lan-server and is not accessable through the internet.

gernot
 
 Wayne Harris wrote : 588
I was able to integrate this clever little calendar with MySQL with these modifications . . .

Code posted here was beginning some months with the date "2", at least on my host`s Linux/Apache/PHP4 server. Was able  to change Brandl`s get_mARRAY() function to get the arrays always to start with "1" (with the first day in the weekrow being Sunday rather than Monday, as is common) by changing the function get_mARRAY() as follows:

function get_mARRAY() { 
    global $intDATE; 
    global $d; 
    global $m; 
    global $j; 
    if (date("w",mktime(0,0,0,$m,1,$j))==1) { 
       $startDAY=mktime(0,0,0,$m,1,$j); 
    } elseif (date("w",mktime(0,0,0,$m,1,$j))==2) { 
       $startDAY=mktime(0,0,0,$m,0,$j);
    } elseif (date("w",mktime(0,0,0,$m,1,$j))==3) { 
       $startDAY=mktime(0,0,0,$m,-1,$j);
    } elseif (date("w",mktime(0,0,0,$m,1,$j))==4) { 
       $startDAY=mktime(0,0,0,$m,-2,$j);
    } elseif (date("w",mktime(0,0,0,$m,1,$j))==5) { 
       $startDAY=mktime(0,0,0,$m,-3,$j);
    } elseif (date("w",mktime(0,0,0,$m,1,$j))==6) { 
       $startDAY=mktime(0,0,0,$m,-4,$j);
    } else { 
       $startDAY=mktime(0,0,0,$m,-5,$j);
    } 
    for ($i=1;$i&lt;=42;$i++) { 
    $marray[$i]=mktime(0,0,0,date("n",$startDAY),date("j",$startDAY)-2+$i,date 
("Y",$startDAY)); 
    } 
return $marray; 


Spelling out the value for each day is a lot clunkier than Brandl`s code but it worked for me.:) But what finally made it all work was inserting that "-2" in ""j",$startDAY)-2+$i" in the for loop.

You can also change "target=_blank" to "target=_self" in the html anchor if you don`t want to open a new window.

The way this little calendar creates numerical year, month and day values (e.g., href=calnav.php?j=2001&m=5&d=1) makes it very easy to assemble a date variable and launch a MySQL query.

Thanks, Brandl.
 
 Gernot Brandl wrote :589
the problem here is:
here in europe, we start each week with monday. some systems report the sunday as weekday 1 (i think, thats`s the american system) of the week. i`m not sure if it`s the php function date() that is responsible for this. if your system reports the monday as day 1 of a week, just change the folloeing line from:
     if (date("w",mktime(0,0,0,$m,1,$j))==2) { //if 1st of reque....
to
    if (date("w",mktime(0,0,0,$m,1,$j))==1) { //if 1st of reque....

i hope, this helps.

gernot