Build A Calender

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Build A Calender

    Here is a code to make calender
    Code:
    <?php
      $monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
        if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
        if (!isset($_REQUEST["year"]))  $_REQUEST["year"]  = date("Y");
        
      $cMonth = $_REQUEST["month"];
      $cYear  = $_REQUEST["year"];
                    
      $prev_year = $cYear;
      $next_year = $cYear;
    
         $prev_month = $cMonth-1;
         $next_month = $cMonth+1;
    
         if ($prev_month == 0 ) {
        $prev_month = 12;
        $prev_year = $cYear - 1;
      }
         if ($next_month == 13 ) {
        $next_month = 1;
        $next_year = $cYear + 1;
      }
    ?>
       <div id="calendar_div" name="calendar_div">
        <table width="200">
            <tr align="center">
              <td bgcolor="#999999" style="color:#FFFFFF">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="50%" align="left">[url="<?php echo $_SERVER["]" style="color:#FFFFFF">Previous[/url]</td>
                          <td width="50%" align="right">[url="<?php echo $_SERVER["]" style="color:#FFFFFF">Next[/url]</td>
                        </tr>
                  </table>
              </td>
            </tr>
            <tr>
                <td align="center">
                  <table width="100%" border="0" cellpadding="2" cellspacing="2">
                    <tr align="center">
                      <td colspan="7" bgcolor="#999999" style="color:#FFFFFF">[b]<?php echo $monthNames[$cMonth-1].&#39; &#39;.$cYear; ?>[/b]</td>
                    </tr>
                    <tr>
                      <td align="center" bgcolor="#999999" style="color:#FFFFFF">[b]S[/b]</td>
                      <td align="center" bgcolor="#999999" style="color:#FFFFFF">[b]M[/b]</td>
                      <td align="center" bgcolor="#999999" style="color:#FFFFFF">[b]T[/b]</td>
                      <td align="center" bgcolor="#999999" style="color:#FFFFFF">[b]W[/b]</td>
                      <td align="center" bgcolor="#999999" style="color:#FFFFFF">[b]T[/b]</td>
                      <td align="center" bgcolor="#999999" style="color:#FFFFFF">[b]F[/b]</td>
                      <td align="center" bgcolor="#999999" style="color:#FFFFFF">[b]S[/b]</td>
                    </tr>
    
                    <?php 
                        $timestamp = mktime(0,0,0,$cMonth,1,$cYear);
                        $maxday    = date("t",$timestamp);
                        $thismonth = getdate ($timestamp);
                        $startday  = $thismonth[&#39;wday&#39;];
    
                      for ($i=0; $i<($maxday+$startday); $i++) {
                        if(($i % 7) == 0 ) echo "<tr>\n";
                        if($i < $startday) echo "<td></td>\n";
                        else echo "<td align=&#39;center&#39; valign=&#39;middle&#39; height=&#39;20px&#39;>". ($i - $startday + 1) . "</td>\n";
                        if(($i % 7) == 6 ) echo "</tr>\n";
                      }  
                     ?>
                  </table>
                </td>
            </tr>
        </table>
    </div>

    #2
    nice thank you, much better than the one i had
    :p:p:p

    Comment


      #3
      thats good got a question though , what will happen in 2009 does it automatically change

      Comment


        #4
        thats good got a question though , what will happen in 2009 does it automatically change[/b]
        you would not ask it if you knew the meaning of
        Code:
         if (!isset($_REQUEST["year"]))  $_REQUEST["year"]  = date("Y");

        Comment


          #5
          you would not ask it if you knew the meaning of
          Code:
           if (!isset($_REQUEST["year"]))  $_REQUEST["year"]  = date("Y");
          [/b]

          i dont know the meaning so why you think i was asking lol some ppl eh

          Comment


            #6
            d:m:y
            is a thingy in php, so the y will automaticly put in the year....

            Click here!!!

            Comment


              #7
              cheers spider for explaining that

              Comment


                #8
                pmsl things like that get data from ya server etc auto
                Want something coded email me at sales@webnwaphost.com for a prices.




                Comment


                  #9
                  It&#39;s a pleasure man

                  Click here!!!

                  Comment


                    #10
                    Mmmmmm i dont get it what dos this do.......do i put it in a page or in a seperate page lol

                    Just kidding...

                    Comment


                      #11
                      This should of gone in Source codes, small scripts... topic... never mind... closed

                      Comment

                      Working...
                      X