Visualizzazione dei risultati da 1 a 4 su 4

Discussione: creare un calendario

  1. #1

    creare un calendario

    ciao, devo creare un calendario e per ogni giorno verificare se c'è un evento.

    il mio problema è come scrivere la tabella dei giorni.

    infatti la tabella dovrà essere :


    lun mar mer gio ven sab dom



    e se il primo di novembre è giovedì, dovrò scriverlo sotto la colonna gio e sulla prima riga.


    come posso fare?

    grazie per i suggerimenti / dritte.
    ciao

  2. #2
    o.0 non puoi usare script già fatti?

  3. #3
    quali mi suggerisci?

    il fatto è che per ogni giorno devo andare a vedere nel db se c'è un evento....

    grazi
    ciao

  4. #4
    Utente di HTML.it
    Registrato dal
    Mar 2003
    Messaggi
    109
    copia e incolla questo codice.....
    è molto semplice da gestire....per ogni giorno aggiungi te i controlli che vuoi (metti degli if etc etc atnto il numero del giorno e del mese e dell'anno ce li hai ogni volta).
    Ti consiglio di aggiungere anche un foglio di stile per rendere carino a l'estetica come ho fatto io, conta che questo è solo lo scheletro funzionante, poi puoi manipolarlo come piu ti piace, ti assicuro che lo puoi far diventare davvero bello.
    Questo ti fa vedere un mese alla volta...se vuoi visualizzare tutto l'anno aggiungi te un ciclo con i relativi parametri per farlo funzionare....
    Spero di esserti stato di aiuto


    <?


    /*

    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'> ".
    "<< </TD>".
    "<TD COLSPAN=5 BGCOLOR='#99CCFF'>".date("F",$first_day)." ".$temp_yr."</TD>".
    "<TD BGCOLOR='white'> ".
    ">> </TD></TR>";

    echo "\n<TR ALIGN='center'><TD>Sun</TD><TD>Mon</TD><TD>Tue</TD>";
    echo "<TD>Wed</TD><TD>Thu</TD><TD>Fri</TD><TD>Sat</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=\"calendar.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();

    ?>
    Le vie del signore sono infinite.....è la segnaletica che lascia a desiderare

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.