Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 网站日历控件_Php_Html_Calendar_Controls - Fatal编程技术网

Php 网站日历控件

Php 网站日历控件,php,html,calendar,controls,Php,Html,Calendar,Controls,我是一个编程初学者,我必须为我的学校项目建立一个网站。 在一些帮助下,我终于建立了一个日历:耶! 但现在我必须浏览我的日历:浏览月份和年份。 例如,今天是2015年1月15日,我想进入2016年,或者1月26日。我真的不知道怎么做…:() 谁能帮帮我吗?我会很感激的:) 我的日历代码: <!DOCTYPE html> <html> <head> </head> <body> <

我是一个编程初学者,我必须为我的学校项目建立一个网站。 在一些帮助下,我终于建立了一个日历:耶! 但现在我必须浏览我的日历:浏览月份和年份。 例如,今天是2015年1月15日,我想进入2016年,或者1月26日。我真的不知道怎么做…:() 谁能帮帮我吗?我会很感激的:) 我的日历代码:

 <!DOCTYPE html>

    <html>
    <head>


    </head>



    <body>

    <?php
    setlocale(LC_ALL, 'nl_NL');
    $today_date = time();


    $day = date('d', $today_date); 
    $month = date('m', $today_date); 
    $year = date('Y', $today_date);

    // Make first day of the month 
    $first_day = mktime(0,0,0,$month, 1, $year); 

    // Get name of the month 
    $title = date('F', $first_day);


    // What day of the week is the first day of the month 
    $day_of_week = date('D', $first_day);

    // Lege plekken invullen
    switch($day_of_week)  { case "Sat": $blank = 6; break;
                        case "Sun": $blank = 0; break; 
                        case "Mon": $blank = 1; break; 
                        case "Tue": $blank = 2; break; 
                        case "Wed": $blank = 3; break; 
                        case "Thu": $blank = 4; break; 
                        case "Fri": $blank = 5; break; 
                         }

    // hoeveel dagen in een maand 
    $days_in_month = cal_days_in_month(0, $month, $year); 

    // Bovenkant

    echo '<table border="0" cellspacing="0" cellpadding="0" width="1500px">  ';     

    echo '<tr><th colspan="7" class = "monthname"> ' .$title . ' ' . $year. ' </th></tr>';  

    echo '<tr> <td width="50" class="weekend">Zondag</td>
           <td width="50" class = "dag">Maandag</td>
           <td width="50" class = "dag">Dinsdag</td>
           <td width="50" class = "dag">Woensdag</td>
           <td width="50" class = "dag">Donderdag</td>
           <td width="50" class = "dag">Vrijdag</td>
           <td width="50" class="weekend">Zaterdag</td>
      </tr>';       

    $day_count = 1;

     echo '<tr>'; 
     // De dagen die er in een maand niet zijn invullen met een leeg vak 
     while ( $blank > 0 ) {
      if ($day_count == 1 || $day_count == 7) {
        echo '<td class="weekend"> </td>';
      } else 
      {echo '<td></td>'; } 

    $blank = $blank - 1; 

    $day_count++; 
       }
    $day_num = 1;

    while ($day_num <= $days_in_month) { if ($day_count == 1 || $day_count == 7) { if ($day_num ==         $day) { echo ' <td class="weekend today">
    <a href="./dag=' .$day_num. '&maand=' .$month. '"> ' .$day_num. ' </a>
    </td>'; } else { echo '

    <td class="weekend">
      <a href="./dag=' .$day_num. '&maand=' .$month. '"> ' .$day_num. ' </a>
    </td>'; } } else { if ($day_num == $day) { echo '

    <td class="today">
      <a href="./dag=' .$day_num. '&maand=' .$month. '"> ' .$day_num. ' </a>
    </td>'; } else { echo '

    <td>
      <a href="./dag=' .$day_num. '&maand=' .$month. '"> ' .$day_num. ' </a>
    </td>'; } } $day_num++; $day_count++; 
    // Seperate the week out onto new lines 
    if ($day_count > 7) { echo '</tr>

      <tr>
    '; $day_count = 1; } } 
    // Blank out days not needed at the end of the month 
    while ($day_count > 1 && $day_count <= 7) { if ($day_count == 1 || $day_count == 7) { echo '<td class="weekend">
    </td>'; } else 
    { echo '<td>
    </td>'; } $day_count++; } 
    // End the table 
    echo '</tr></table>';



    ?>
</div>
</body>
</html>

您可以使用两个Get变量来完成此操作。m(月)和y(年)。 更改行:

$month = date('m', $today_date); 
$year = date('Y', $today_date);
进入:

现在,您可以使用月份和年份调用脚本:

?m=3&y=2014
这是您对2014年3月的看法。 您可以创建下一个和上一个链接,用y和m Get变量调用脚本。

尝试使用mktime()而不是time()


mktime函数的参数应通过GET变量传输。

首先生成
$today\u date
变量,如
$today\u date=isset($\u GET['timestamp'))?intval($_GET['timestamp']):time()
以便您可以根据url请求不同的日历。然后添加适当的链接,将天/月/年(以秒为单位)添加和减去该数字。我想浏览日历,我的意思是添加一个按钮“明年”,转到2016年。还有一个“下个月”按钮,可以转到二月而不是一月。我真的不知道怎么做。。
?m=3&y=2014