Visualizzazione dei risultati da 1 a 2 su 2

Discussione: script calendario

  1. #1

    script calendario

    Salve a tutti,
    ho scaricato lo script di un calendario perpetuo...
    tutto bene finchè stai al mese corrente...
    quando visualizzi il mese successivo o il precedente il primo giorno del mese non è in sequenza.
    Purtroppo non sono esperta, mi potete aiutare?!

    ecco il codice:
    Codice PHP:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>PHP CSS Calendar Example</title>
    <link href="calendar.css" rel="stylesheet" type="text/css" />
    </head>

    <body>
    <h3>PHP CSS Calendar Example</h3>
    <table id="calendar" cellspacing="0" cellpadding="0" summary="This month's calendar">
    <?php

    $day 
    = @$_GET["day"];
    $month = @$_GET["month"];
    $year = @$_GET["year"];

    if (
    $month == ""){ 
        
    $day date('d');
        
    $month date('n');
        
    $year date('Y');
    }
    $firstOfMonthDateStamp mktime(125959$month1$year);

    $daysInCurrentMonth date("t"$firstOfMonthDateStamp);
    $firstOfMonthDay date("d"$firstOfMonthDateStamp);
    $lastOfMonthDay date("w"strtotime(date("n",$firstOfMonthDateStamp)."/".$daysInCurrentMonth."/".date("Y",$firstOfMonthDateStamp)));
    $previousMonth getdate(strtotime('-1 month'$firstOfMonthDateStamp));
    $nextMonth getdate(strtotime('+1 month'$firstOfMonthDateStamp));
    ?>
    <caption>[url="calendar.php?day=<?php echo $day ?>&amp;month=<?php echo $previousMonth['mon'?>&amp;year=<?php echo $previousMonth['year'?>"])">&lt;&lt;[/url] <?php echo date("F"$firstOfMonthDateStamp?>  <?php echo date("Y",$firstOfMonthDateStamp?> [url="calendar.php?day=<?php echo $day ?>&amp;month=<?php echo $nextMonth['mon'?>&amp;year=<?php echo $nextMonth['year'?>"])">&gt;&gt;[/url]</caption>
      <tr><th abbr="Sunday" title="Sunday">S</th><th abbr="Monday" title="Monday">M</th><th abbr="Tuesday" title="Tuesday">T</th><th abbr="Wednesday" title="Wednesday">W</th><th abbr="Thursday" title="Thursday">T</th><th abbr="Friday" title="Friday">F</th><th abbr="Saturday" title="Saturday">S</th></tr>
    <tr>
    <?php
    //ASP/PHP WRITTEN BY BOB MCKAY, [url]WWW.FRESHMANGO.COM[/url] - USE AS YOU WISH BUT PLEASE LEAVE THIS IN PLACE
    //DESIGN, CSS AND XHTML ALL BY VEERLE, [url]HTTP://VEERLE.DUOH.COM[/url]
    $columnCounter 0;
    //FOR fillLeadingEmptyDays = 1 TO ($firstOfMonthDay - 1)
    for ($fillLeadingEmptyDays=0$fillLeadingEmptyDays <= ($firstOfMonthDay 1); $fillLeadingEmptyDays+=1) { 
        
    $columnCounter $columnCounter 1;
        echo 
    "<td></td>";
    }
    for (
    $enterDays=1$enterDays <= $daysInCurrentMonth$enterDays+=1) { 
        
    $columnCounter $columnCounter 1;
        echo 
    "<td><a ";
        if (
    $enterDays == $day) { echo " class = \"today\""; }
        
    $dayLinkDestination "#";
        echo 
    " href=\"".$dayLinkDestination."\">".$enterDays."</a></td>";
        if ( 
    $columnCounter == ) {
            echo 
    "</tr><tr>";
            
    $columnCounter 0;
        }
    }
    for (
    $fillEmptyDays=($columnCounter 1); $fillEmptyDays <= 7$fillEmptyDays+=1) { 
        if (
    $columnCounter ==0) {
            break;
        }
        echo 
    "<td></td>";

    }
    ?></tr>
    </table>
    </body>
    </html>

  2. #2

    Calendario eventi

    ciao a tutti.
    Ne ho trovato un altro che va alla grande....

    Però, non essendo troppo esperta, non riesco a modificarlo come serve a me...
    e cioè:

    Invece di visualizzarmi il giorno corrente (in questo caso la casella diviene a sfondo celeste),
    io avrei bisogno che mi si visualizzassero i giorni in cui è presente un evento nel DB MySql.
    La data viene inserita nel DB come campo 'date'.
    Mi potreste dare una mano?!
    Vi posto il codice:
    Codice PHP:
    <?
    /*

    Please keep the following lines if you will use this script. Thanks!
    ---------------------------------------------------------------------------
    CALENDAR SCRIPT
    Developed by : Steven Rebello (stevenrebello@indiatimes.com)
    Developed on : 15 September 2001
    Description : Prints a calendar for specified month and year in HTML

    ---------------------------------------------------------------------------

    To use this calendar script, just add the following function

    print_calendar($mon,$year);

    into your code and
    place the function call print_calendar($month,$year) where you want the calendar to be printed.
    The function get_month_as_array

    $month and $year are integers.
    For eg. the following will print calendar for December 2001.

    print_calendar(12,2001);

    You can tweak the table properties as you like.
    I did not want to complicate the function call with table property parameters like bordercolor etc..

    */

    //----------------- This function is to do the HTML header chore---------------------
    function print_HTML_header()
    {
    echo 
    "<HTML>\n<HEAD>\n<STYLE>\n".
    "\n</STYLE>".
    "<TITLE>Calendar\n</TITLE>\n</HEAD>\n<BODY BACKGROUND='images/bg.gif'>\n\n";
    }


    //----------------- This function is to do the HTML footer chore---------------------
    function print_HTML_footer()
    {
    echo 
    "</BODY></HTML>";
    }



    //----------------- This function prints calendar---------------------
    function print_calendar($mon,$year)
    {
    global 
    $dates$first_day$start_day;

    $first_day mktime(0,0,0,$mon,1,$year);
    $start_day date("w",$first_day);
    $res getdate($first_day);
    $month_name $res["month"];
    $no_days_in_month date("t",$first_day);

    //If month's first day does not start with first Sunday, fill table cell with a space
    for ($i 1$i <= $start_day;$i++)
    $dates[1][$i] = " ";

    $row 1;
    $col $start_day+1;
    $num 1;
    while(
    $num<=31)
    {
    if (
    $num $no_days_in_month)
    break;
    else
    {
    $dates[$row][$col] = $num;
    if ((
    $col 1) > 7)
    {
    $row++;
    $col 1;
    }
    else
    $col++;
    $num++;
    }
    //if-else
    }//while
    $mon_num date("n",$first_day);
    $temp_yr $next_yr $prev_yr $year;

    $prev $mon_num 1;
    $next $mon_num 1;

    //If January is currently displayed, month previous is December of previous year
    if ($mon_num == 1)
    {
    $prev_yr $year 1;
    $prev 12;
    }

    //If December is currently displayed, month next is January of next year
    if ($mon_num == 12)
    {
    $next_yr $year 1;
    $next 1;
    }

    echo 
    "<DIV ALIGN='right'><TABLE BORDER=1 WIDTH=40% CELLSPACING=0 BORDERCOLOR='silver'>";

    echo 
    "\n<TR ALIGN='center'><TD BGCOLOR='white'> ".
    "[url='calendario.php?month=$prev&year=$prev_yr'][B]<<[/B][/url] </TD>".
    "<TD COLSPAN=5 BGCOLOR='#99CCFF'>[B]".date("F",$first_day)." ".$temp_yr."[/B]</TD>".
    "<TD BGCOLOR='white'> ".
    "[url='calendario.php?month=$next&year=$next_yr'][B]>>[/B][/url] </TD></TR>";

    echo 
    "\n<TR ALIGN='center'><TD>[B]Sun[/B]</TD><TD>[B]Mon[/B]</TD><TD>[B]Tue[/B]</TD>";
    echo 
    "<TD>[B]Wed[/B]</TD><TD>[B]Thu[/B]</TD><TD>[B]Fri[/B]</TD><TD>[B]Sat[/B]</TD></TR>";
    echo 
    "<TR><TD COLSPAN=7> </TR><TR ALIGN='center'>";

    $end = ($start_day 4)? 6:5;
    for (
    $row=1;$row<=$end;$row++)
    {
    for (
    $col=1;$col<=7;$col++)
    {
    if (
    $dates[$row][$col] == "")
    $dates[$row][$col] = " ";

    if (!
    strcmp($dates[$row][$col]," "))
    $count++;

    $t $dates[$row][$col];

    //If date is today, highlight it
    if (($t == date("j")) && ($mon == date("n")) && ($year == date("Y")))
    echo 
    "\n<TD BGCOLOR='aqua'>".$t."</TD>";
    else
    //If the date is absent ie after 31, print space
    echo "\n<TD>".(($t == " " )? " " :$t)."</TD>";
    }
    // for -col

    if (($row 1) != ($end+1))
    echo 
    "</TR>\n<TR ALIGN='center'>";
    else
    echo 
    "</TR>";
    }
    // for - row
    echo "\n</TABLE>

    <A HREF=\"calendario.php\">Show Current month</A> </DIV>"
    ;
    }




    //----------Main Loop-----------

    print_HTML_header();

    //If $month is not present, set it to current month.
    $month = (empty($month)) ? date("n") : $month;

    //If $year is not present, set it to current year.
    $year = (empty($year)) ? date("Y") : $year;

    print_calendar($month,$year);

    print_HTML_footer();

    ?>
    Grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.