Results 1 to 7 of 7

Thread: Simple php calendar script

  1. #1
    Join Date
    Sep 2004
    Location
    Martil
    Age
    29
    Posts
    19,386
    Rep Power
    109855

    Default Simple php calendar script

    When you search from google for php calendar you will get lot of free and comercial script for this purpose. But my problem is that all those php calendar script is hard to implement and to modify. So I decided to create my own simple calendar script, and share to those who are looking for this kind of script and want to modify it.
    PHP Code:
    $x=$_GET[x];
    if(
    $x==""$x date("n");

    $date strtotime("2006/$x/1");
    $day date("D",$date);
    $m date("F",$date);
    $totaldays date("t",$date); //get the total day of specified date

    echo "<table border = '1' cellspacing = '0' bordercolor='blue' cellpadding ='2'><tr>
    <td colspan='7'>$m</td></tr>
    <tr>
    <td><font size = '1' face = 'tahoma'>Sun</font></td>
    <td><font size = '1' face = 'tahoma'>Mon</font></td>
    <td><font size = '1' face = 'tahoma'>Tue</font></td>
    <td><font size = '1' face = 'tahoma'>Wed</font></td>
    <td><font size = '1' face = 'tahoma'>Thu</font></td>
    <td><font size = '1' face = 'tahoma'>Fri</font></td>
    <td><font size = '1' face = 'tahoma'>Sat</font></td>
    </tr>
    "
    ;

    if(
    $day=="Sun"$st=1;
    if(
    $day=="Mon"$st=2;
    if(
    $day=="Tue"$st=3;
    if(
    $day=="Wed"$st=4;
    if(
    $day=="Thu"$st=5;
    if(
    $day=="Fri"$st=6;
    if(
    $day=="Sat"$st=7;

    if (
    $st >= && $totaldays == 31) {
    $tl=42;
    }elseif(
    $st == && $totaldays == 30){
    $tl 42;
    }else{
    $tl 35;
    }

    $ctr 1;
    $d=1;

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

    if(
    $ctr==1) echo "<tr>";

    if(
    $i >= $st && $d <= $totaldays){
    echo 
    "<td align='center'><font size = '2' face = 'tahoma'>$d</font></td>";
    $d++;
    }
    else{
    echo 
    "<td>&nbsp</td>";
    }

    $ctr++;

    if(
    $ctr 7) {
    $ctr=1;
    echo 
    "</tr>";
    }

    }

    $prev=$x 1;
    $next $x 1;
    if(
    $prev==0$prev=1;
    if(
    $next==13$next 12;
    echo 
    "</table><b><a href = 'calendar.php?x=$prev'>Previous</a>                  <a href = 'calendar.php?x=$next'>Next</a></b>"
    -
    -


    **FAQ**


    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
    [Only registered and activated users can see links. ]
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
    [Only registered and activated users can see links. ]
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
    [Only registered and activated users can see links. ]
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

  2.    Advertissements


  3. #2

    Default

    Great calender, by far the best and simplest I could find anywhere, although you need to manually enter the year and it can not change past the current year, the following simple changes I made fixes this if you want to add them...

    change top from...
    $x=$_GET[x];
    if($x=="") $x = date("n");

    $date = strtotime("2006/$x/1");
    to...
    $x=$_GET[x];
    $theyear=$_GET[theyear];
    if($x=="") $x = date("n");
    if ($theyear == ""){
    $start = 20;
    $theyear = $start.''.date("y");
    }
    $date = strtotime("$theyear/$x/1");

    and bottom from...
    if($prev==0) $prev=1;
    if($next==13) $next = 12;
    echo "</table><b><a href = 'calendar.php?x=$prev'>Previous</a> <a href = 'calendar.php?x=$next'>Next</a></b>";
    to...
    $theprevyear = $theyear;
    $thenextyear = $theyear;
    if($prev==0) {
    $prev=12;
    $theprevyear = $theyear-1;
    }
    if($next==13) {
    $next = 1;
    $thenextyear = $theyear+1;
    }
    echo "</table><b><a href = 'view_calendar.php?x=$prev&theyear=$theprevyear'>P revious</a> <a href = 'view_calendar.php?x=$next&theyear=$thenextyear'>N ext</a></b>";

    I think those are the only changes I had to make, gives the calendar much more functionality with very little change in code
    Last edited by gamebuster5; 21-05-2009 at 10:46 PM.

  4. #3

    Smile

    Thanks spiral, and thanks gamebuster for those additions to the script. I've been searching for a simple calendar I can modify to link to an events database and this looks like the one. To make it easier to test I wrote a piece of code to get straight to the calendar:
    HTML Code:
    <form action="view_calendar.php" method="get" name="myform">
    Month <input name="x" type="text" size="10" /><br />
    Year<input name="theyear" type="text" size="10" />
    <input name="submit" type="submit" />
    </form>

  5. #4

    Default new addition--highlight current date

    sir this script had helped me a lot tnx...
    i wanted to show you this little addition to your script..
    .
    .
    .
    if($ctr==1) echo "<tr>";

    if($i >= $st && $d <= $totaldays){
    if($d==date('j')) echo "<td align='center' style='background-color:#CCCCCC'><font size = '2' face = 'tahoma'>$d</font></td>";
    else echo "<td align='center'><font size = '2' face = 'tahoma'>$d</font></td>";


    $d++;
    .
    .
    .

    this will highlight the current date
    Last edited by nicolaikitty; 03-01-2010 at 01:46 PM.

  6. #5
    Join Date
    Jan 2009
    Location
    -""LifePDA""-""Mozambique""-
    Age
    17
    Posts
    1,960
    Rep Power
    120414

    Arrow Go And Introduce Yourself !

    Quote Originally Posted by nicolaikitty View Post
    sir this script had helped me a lot tnx...
    i wanted to show you this little addition to your script..
    .
    .
    .
    if($ctr==1) echo "<tr>";

    if($i >= $st && $d <= $totaldays){
    if($d==date('j')) echo "<td align='center' style='background-color:#CCCCCC'><font size = '2' face = 'tahoma'>$d</font></td>";
    else echo "<td align='center'><font size = '2' face = 'tahoma'>$d</font></td>";


    $d++;
    .
    .
    .

    this will highlight the current date
    Hello mate!!...Before starting posting go [Only registered and activated users can see links. ] to presentate/introduce yourself, and follow this guide: [Only registered and activated users can see links. ]
    Thank u..
    Regards!!
    Transparent wallpaper with name request[[Only registered and activated users can see links. ]]
    " The secret of success is to know something nobody else knows. "
    Pritesh - Noeman Ex-Moderator

  7. #6

    Arrow

    great scrpit post.

  8. #7

    Default

    PHP simple calendar, you can simple to compress a CSS file to actually the color, font size, table size. PHP is very simple to take over full control of the appearance of the calendar and how it interacts with users! With a number of the date, time and language formats, easy PHP calendar that can be used anywhere in the world! Easy PHP Calendar is also supported through the user forums. Take the time to watch the on line demo, download a free trial version, you will see a simple PHP calendar PHP script for your calendar!
    [Only registered and activated users can see links. ]

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219