• User Attivo

    Calendario eventi

    Ciao ragazzi, ho trovato questo script su internet

    [php]<?php

    if (empty($_GET['month'])) {
    $month = date('n');
    } else {
    $month = $_GET['month'];
    }

    if (empty($_GET['year'])) {
    $year = date('Y');
    } else {
    $year = $_GET['year'];
    }

    $nomemese = array (1 => "Gennaio", "Febbraio", "Marzo", "Aprile",
    "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre");

    $theday = date('w', mktime(0, 0, 0, $month, 1, $year));

    $daysinmonth = date("t", mktime(0, 0, 0, $month, 1, $year));
    ?>

    <table cellspacing="1" cellpadding="0" border="0" class="mainTable">
    <tr>
    <td align="center" colspan="7" class="monthRow">
    <a href="<?php echo $_SERVER['PHP_SELF']; if ($month == '01') { $prevmonth = '12'; $prevyear = $year - 1; echo '?month=' . $prevmonth; echo '&year=' . $prevyear; } else { $prevmonth = $month - 1; echo '?month=' . $prevmonth; echo '&year=' . $year; } ?>">«</a>
    <?php
    $monthName = date('F', mktime(0, 0, 0, $month, 1, $year));
    $yearName = date('Y', mktime(0, 0, 0, $month, 1, $year));
    echo $nomemese[$month] . ' ' . $yearName;
    ?>
    <a href="<?php echo $_SERVER['PHP_SELF']; if ($month == '12') { $nextmonth = '01'; $nextyear = $year + 1; echo '?month=' . $nextmonth; echo '&year=' . $nextyear; } else { $nextmonth = $month + 1; echo '?month=' . $nextmonth; echo '&year=' . $year; } ?>">»</a>
    </td>
    </tr>
    <tr class="dayNamesText">
    <td class="dayNamesRow" width="25" align="center">L</td>
    <td class="dayNamesRow" width="25" align="center">M</td>
    <td class="dayNamesRow" width="25" align="center">M</td>
    <td class="dayNamesRow" width="25" align="center">G</td>
    <td class="dayNamesRow" width="25" align="center">V</td>
    <td class="dayNamesRow" width="25" align="center">S</td>
    <td class="dayNamesRow" width="25" align="center">D</td>
    </tr>

    <tr class="rows">
    <?php
    for ($i = 0; $i < $theday; $i++) {
    ?>
        <td>&nbsp;</td>
    <?php
    }
    for ($list_day = 2; $list_day <= $daysinmonth; $list_day++) {
        $tm = date("U", mktime(0, 0, 0, $month, $list_day, $year)) - 86400; // Bir gün önce
        $tn = date("U", mktime(0, 0, 0, $month, $list_day, $year)); // O gün ...
        $tp = date("U", mktime(0, 0, 0, $month, $list_day, $year)) + 86400; // Bir gün sonra
        $Q = sprintf("SELECT * FROM `events` WHERE `date` > '%s' AND `date` < '%s' AND `day` = '%s';", $tm, $tp, $list_day);
        $R = mysql_query($Q);
        $D = mysql_fetch_assoc($R);
        $S = mysql_num_rows($R);
        $Y = $D['date'];
        $TheDay = date('d', $Y);
        $TheMon = date('F', $Y);
        $TheYea = date('Y', $Y);
        mysql_free_result($R);
        if ($S) {
        ?>
            <td align="center" onClick="eventipopup(<?php echo $D['day']; ?>, <?php echo $D['month']; ?>, <?php echo $D['year']; ?>, 600, 520)" style="background-color: #CCFF00; color: #333333; cursor: pointer;" onMouseOver="return overlib('&lt;table width=&quot;100%&quot; border=&quot;0&quot; cellpadding=&quot;2&quot; cellspacing=&quot;0&quot; class=&quot;popupDateTable&quot;&gt;&lt;tr&gt;&lt;td align=&quot;center&quot; class=&quot;popupDate&quot;&gt;<?php echo $TheDay; ?> <?php echo $nomemese[$month]; ?> <?php echo $TheYea; ?>&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;div class=&quot;popupEventTitle s23&quot;&gt;<?php echo $S; ?> Evento(i) &lt;/div&gt;');" onMouseOut="return nd();" title="">
        <?php
        } elseif ($tn > $tm AND $tn < $tp AND date('j') == $list_day AND date('m') == $month AND date('Y') == $year) {
        ?>
            <td align="center" style="background-color: #FFC18A; color: #CF0000; cursor: pointer;" onMouseOver="return overlib('&lt;div style=&quot;background-color:; color:; padding: 4px;&quot;&gt;Oggi&lt;/div&gt;');" onMouseOut="return nd();">
        <?php
        } elseif ($theday == 6 or $theday == 0) {
        ?>
            <td align="center" style="background-color: #EEEEEE; color: #666666;">
        <?php
        } else {
        ?>
            <td align="center" style="background-color: #CCCCCC; color:;">
        <?php
        }
        
        echo $list_day;
    
        echo '</td>';
    
        if ($theday == 6) {
            echo '</tr>';
            echo '<tr class="rows">';
            $theday = -1;
        }
    $theday++;
    

    }
    ?>[/php]Serve esattamente a creare un calendario online, però mi comincia a contare ogni volta dal giorno 2 al 30 o 31 (in base al mese)

    E non capisco come far apparire anche il primo del mese..

    Avete qualche idea??

    :ciauz::ciauz:


  • User Attivo

    ti allego calendario da me modificato per eventi con db

    htt.:..w14.easy-share.co_/1701083031.html


  • User Attivo

    Adesso lo provo 😉

    Zau e grazie


  • User Attivo

    Perfetto grazie mille 😉

    Sei stato gentilissimo....

    Zau zau


  • User Attivo

    Ciao ragazzi,

    per la cronaca, penso che la "colpa" fosse di questa riga di codice

    [PHP]for ($list_day = 2; $list_day <= $daysinmonth; $list_day++)[/PHP]

    Come si puo' vedere $list_day parte dal valore 2.

    Ciao ciao


  • User Attivo

    Ciao ragazzi, grazie a tutti per l'aiuto, adesso avrei questo problemino vorrei che quando insersco una news aggiungo un campo dal giorno al giorno in modo che se io metto dal 10 agosto 2008 al 21 agosto 2008 mi si aggiunta in ogni giorno lo stesso evento..

    E' possibile fare una cosa del genere?? Avete qualche idea su come potrei fare questa cosa?? ⭕o

    :ciauz::ciauz: