Salta al contenuto
  • CATEGORIES
  • La Community Connect.gt
  • Presentati alla Community
  • News Ufficiali da Connect.gt
  • Internet News
  • A Scuola Di
  • Digital Marketing
  • Intelligenza Artificiale
  • SEO & GEO
  • Web Marketing e Content
  • Google Analytics e Web Analytics
  • Google Ads & Advertising
  • YouTube
  • TikTok, Instagram e altri Social
  • Google Adsense, Affiliazioni e Guadagno
  • E-Commerce
  • Coding e Sistemistica
  • Help Center: consigli per il tuo progetto
  • Hosting e Cloud
  • Coding
  • CMS & Piattaforme Self-Hosted
  • Annunci e Collaborazioni
  • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
  • Collaborazioni WEB e Lavoro: offro e cerco
  • Impresa, Fisco e Leggi
  • Consulenza Legale e Professioni Web
  • Consulenza Fiscale, Imprese, Startup e P.Iva
  • Gli Off Topic
  • PC, Smartphone e altri Hardware
  • Tutti i Software
  • GT Fetish Cafè
  • Discussioni
  • 0 Non letti 0
  • Recenti
  • Hashtag
  • Popolare
  • Utenti
  • Privacy
  • Termini e condizioni
  • © 2026 Search On Media Group S.r.l.
Collassa
Connect.gt
Il network Search On
Connect.gt WMF AI Festival Accademia Advanced SEO Tool AgentCy Social Media Strategies Search Tech
Registrati Accedi
Connect.gt
Stream Interest Categorie Hashtag
  1. La community italiana di SEO, marketing digitale e AI
  2. Categorie
  3. Coding e Sistemistica
  4. Coding
  5. Problema calendario php

Problema calendario php

Pianificato Fissato Bloccato Spostato Coding
5 Post 2 Autori 996 Visualizzazioni 1 Seguito
  • Da Vecchi a Nuovi
  • Da Nuovi a Vecchi
  • Più Voti
Rispondi
  • Risposta alla discussione
Effettua l'accesso per rispondere
Questa discussione è stata eliminata. Solo gli utenti con diritti di gestione possono vederla.
  • T
    T
    thaypan
    scritto su ultima modifica di
    User Newbie 0
    #1
    Problema calendario php

    Ciao, ho trovato su internet un piccolo script in php per un calendario... l'unico problema è che è quadrato... mentre io avrei bisogno che fosse rettangolare cioè non in base ai giorni dal lunedì alla domenica ma in base ai giorni di calendario avendo solo due righe una con i giorni del mese (1,2,3,4,...., 31) e una con i giorni della settimana (L,M,M,G,V,S,D)...
    Ho provato a modificare i paramenti da solo ma dopo molti tentativi (alla cieca) mi sto arrendendo...
    Qualcuno sa come modificarlo? Almeno per farlo uscire rettangolare invece che quadrato?
    Grazie mille
    Ciao

    <?php 
    
    // if ym is set, i.e. somebody clicked on next or previous months link 
    if(isset($_GET["ym"])) 
    { 
        $year = (int)substr($_GET["ym"], 0, 4); 
        $month = (int)substr($_GET["ym"], 4, 2); 
    } 
    else    // otherwise take current month & year 
    { 
        $month = date("m", mktime(0,0,0,date('m'),1,date('Y'))); 
        $year = date("Y", mktime(0,0,0,date('m'),1,date('Y'))); 
    } 
    
    $skip = date("w", mktime(0,0,0,$month,1,$year)); // days to skip in 1 row of week. 
    $daysInMonth = date("t", mktime(0,0,0,$month,1,$year));    // total number of dates in the month. 
    $calendar_head = '';    // for calendar head 
    $calendar_body = '';    // for calendar boday 
    $day = 1;    // For date in calendar 
    
    for($i = 0; $i < 6; $i++) // Outer loop for weeks 
    { 
        $calendar_body .= '<tr>';    // start row tag 
        for($j = 0; $j < 7; $j++)    // Inner loop for week days 
        { 
            if(($skip > 0)||($day > $daysInMonth)) // display blank till 1 day of month or after total numnber of days in that month 
            { 
                $calendar_body .= '<td>&nbsp;</td>';  
                $skip--; 
            } 
            else 
            { 
                if($j == 0)    // if its Sunday then add class holiday 
                    $calendar_body .= '<td class="holiday">'.$day.'</td>';  
                else    // otherwise add day class 
                    $calendar_body .= '<td class="day">'.$day.'</td>';  
                     
                $day++; // Increment $day 
            } 
             
        }    // inner loop closes 
        $calendar_body .= '</tr>'; // end row tag 
    } // outer loop closes 
    
    // Calendar head section 
    $calendar_head = ' 
      <tr>       
        <th colspan="2"><a href="?ym='.date("Ym", mktime(0,0,0,$month-1,1,$year)).'">&laquo; Previous Month</a></th> 
          <th colspan="3">'.date("F, Y", mktime(0,0,0,$month,1,$year)).'</th> 
          <th colspan="2"><a href="?ym='.date("Ym", mktime(0,0,0,$month+1,1,$year)).'">Next Month &raquo;</a></th> 
      </tr> 
      <tr> 
        <th>Sunday</th> 
        <th>Monday</th> 
        <th>Tuesday</th> 
        <th>Wednesday</th> 
        <th>Thursday</th> 
        <th>Friday</th> 
        <th>Saturday</th> 
      </tr>'; 
    // PHP code for calendar ends 
       
    ?> 
       
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
    <title>A Calendar Built in PHP</title> 
    
    <style type="text/css"> 
    
    #calendar tbody tr{ height:100px; } 
    #calendar td{ width:100px; } 
    #calendar th{background-color:#CCCC99;} 
    .day{ background-color:#CCFFCC; } 
    .holiday{ background-color:#FFCC66; } 
    
    </style> 
    
    </head> 
    
    <body> 
    
    <h2>A Calendar Built in PHP</h2> 
    
    <!-- Table to display calendar --> 
    <table id="calendar" width="710" border="1" cellspacing="0" cellpadding="5"> 
    <thead>  
      <?php echo $calendar_head; ?> 
    </thead> 
    <tbody> 
        <?php echo $calendar_body; ?> 
    </tbody> 
    </table> 
    <!-- Table to display calendar --> 
    
    </body> 
    </html>
    
    1 Risposta Ultima Risposta
    Miglior risposta 0
    0
    • C
      C
      cyrus
      scritto su ultima modifica di
      User 0
      #2

      Ciao,
      intendevi in questa maniera?

      <?php 
      
      // if ym is set, i.e. somebody clicked on next or previous months link 
      if(isset($_GET["ym"])) 
      { 
          $year = (int)substr($_GET["ym"], 0, 4); 
          $month = (int)substr($_GET["ym"], 4, 2); 
      } 
      else    // otherwise take current month & year 
      { 
          $month = date("m", mktime(0,0,0,date('m'),1,date('Y'))); 
          $year = date("Y", mktime(0,0,0,date('m'),1,date('Y'))); 
      } 
      
      $skip = date("w", mktime(0,0,0,$month,1,$year)); // days to skip in 1 row of week. 
      $daysInMonth = date("t", mktime(0,0,0,$month,1,$year));    // total number of dates in the month. 
      $calendar_head = '';    // for calendar head 
      $calendar_body = '';    // for calendar boday 
      $day = 1;    // For date in calendar 
      
      $calendar_body .= '<tr>';
      for($i = 0; $i < 6; $i++) // Outer loop for weeks 
      { 
          //$calendar_body .= '<tr>';    // start row tag 
          for($j = 0; $j < 7; $j++)    // Inner loop for week days 
          { 
              if(($skip > 0)||($day > $daysInMonth)) // display blank till 1 day of month or after total numnber of days in that month 
              { 
                  $calendar_body .= '<td>&nbsp;</td>';  
                  $skip--; 
              } 
              else 
              { 
                  if($j == 0)    // if its Sunday then add class holiday 
                      $calendar_body .= '<td class="holiday">'.$day.'</td>';  
                  else    // otherwise add day class 
                      $calendar_body .= '<td class="day">'.$day.'</td>';  
                       
                  $day++; // Increment $day 
              } 
               
          }    // inner loop closes 
          //$calendar_body .= '</tr>'; // end row tag 
      } // outer loop closes 
      $calendar_body .= '</tr>';
      
      // Calendar head section 
      $calendar_head = ' 
        <tr>       
          <th colspan="2"><a href="?ym='.date("Ym", mktime(0,0,0,$month-1,1,$year)).'">&laquo; Previous Month</a></th> 
            <th colspan="3">'.date("F, Y", mktime(0,0,0,$month,1,$year)).'</th> 
            <th colspan="2"><a href="?ym='.date("Ym", mktime(0,0,0,$month+1,1,$year)).'">Next Month &raquo;</a></th> 
        </tr> 
        <tr> ';
      for($i = 0; $i < 6; $i++) // Outer loop for weeks 
      {   
      	$calendar_head .= '
          <th>Sunday</th> 
          <th>Monday</th> 
          <th>Tuesday</th> 
          <th>Wednesday</th> 
          <th>Thursday</th> 
          <th>Friday</th> 
          <th>Saturday</th>'; 
      } // outer loop closes 
      
      // PHP code for calendar ends 
         $calendar_head .= ' </tr>';
      ?>
      
      1 Risposta Ultima Risposta
      Miglior risposta 0
      0
      • T
        T
        thaypan
        scritto su ultima modifica di
        User Newbie 0
        #3

        ciao, ho provato proprio ora il tuo script ma non va... uso EasyPHP... mi esce la pagina completamente bianca... come mai ?

        1 Risposta Ultima Risposta
        Miglior risposta 0
        0
        • C
          C
          cyrus
          scritto su ultima modifica di
          User 0
          #4

          Nel post sopra non ti ho copiato la parte in html dato che rimane identica (dal tag <head> in avanti)

          1 Risposta Ultima Risposta
          Miglior risposta 0
          0
          • T
            T
            thaypan
            scritto su ultima modifica di
            User Newbie 0
            #5

            Cyrus

            Nel post sopra non ti ho copiato la parte in html dato che rimane identica (dal tag <head> in avanti)

            si una cosa del genere solo che esciono delle tabelle in più che sono vuote... mentre i giorni del mese dovrebbero corrispondere ai giorni della settimana...
            Ho provato anche io così ma si presentava tutto sballato

            1 Risposta Ultima Risposta
            Miglior risposta 0
            0

            Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.

            Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.

            Con il tuo contributo, questo post potrebbe essere ancora migliore 💗

            Registrati Accedi
            Rispondi
            • Risposta alla discussione
            Effettua l'accesso per rispondere
            • Da Vecchi a Nuovi
            • Da Nuovi a Vecchi
            • Più Voti


            • Accedi

            • Non hai un account? Registrati

            • Accedi o registrati per effettuare la ricerca.
            • Primo post
              Ultimo post
            Home Accedi Registrati
            Menu
            • CATEGORIES
            • La Community Connect.gt
            • Presentati alla Community
            • News Ufficiali da Connect.gt
            • Internet News
            • A Scuola Di
            • Digital Marketing
            • Intelligenza Artificiale
            • SEO & GEO
            • Web Marketing e Content
            • Google Analytics e Web Analytics
            • Google Ads & Advertising
            • YouTube
            • TikTok, Instagram e altri Social
            • Google Adsense, Affiliazioni e Guadagno
            • E-Commerce
            • Coding e Sistemistica
            • Help Center: consigli per il tuo progetto
            • Hosting e Cloud
            • Coding
            • CMS & Piattaforme Self-Hosted
            • Annunci e Collaborazioni
            • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
            • Collaborazioni WEB e Lavoro: offro e cerco
            • Impresa, Fisco e Leggi
            • Consulenza Legale e Professioni Web
            • Consulenza Fiscale, Imprese, Startup e P.Iva
            • Gli Off Topic
            • PC, Smartphone e altri Hardware
            • Tutti i Software
            • GT Fetish Cafè
            • Discussioni
            • Non letti 0
            • Recenti
            • Hashtag
            • Popolare
            • Utenti
            • Privacy
            • Termini e condizioni
            • © 2026 Search On Media Group S.r.l.