帮助,php日历链接

帮助,php日历链接,php,calendar,Php,Calendar,下面是一个部分表行,它将创建一个包含3列的行。 两边的两列是链接,左边是上一年的链接,右边是下一年的链接。 中心是从一月到十二月的链接 当您单击月份链接时,日历将显示您在日历所在的当前年份中单击的月份。例如,日历将默认打开当前月份和年份…2010年3月。如果单击上一年(2009年),它将显示上一年(2009年)的当前月份(3月)……然后,如果单击六月,日历将显示日历当前所在年份的六月,即2009年的六月 我的问题是,我可以对下面的代码做什么来做这样的事情 $Calendar.= "</tr

下面是一个部分表行,它将创建一个包含3列的行。 两边的两列是链接,左边是上一年的链接,右边是下一年的链接。 中心是从一月到十二月的链接

当您单击月份链接时,日历将显示您在日历所在的当前年份中单击的月份。例如,日历将默认打开当前月份和年份…2010年3月。如果单击上一年(2009年),它将显示上一年(2009年)的当前月份(3月)……然后,如果单击六月,日历将显示日历当前所在年份的六月,即2009年的六月

我的问题是,我可以对下面的代码做什么来做这样的事情

$Calendar.= "</tr><tr><td>"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=" . $LastYear["year"] ."\"> $LastY </a></td>\n";
$Calendar.= "<td colspan=\"5\">"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[0] ."\">Jan.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[1] ."\">Feb.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[2] ."\">Mar.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[3] ."\">Apr.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[4] ."\">May</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[5] ."\">Jun.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[6] ."\">Jul.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[7] ."\">Aug.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[8] ."\">Sep.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[9] ."\">Oct.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[10] ."\">Nov.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[11] ."\">Dec.</a>
              </td>";
$Calendar.= "<td>"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=" . $NextYear["year"] ."\"> $NextY </a></td>\n";
$Calendar.=”.\n”;
$Calendar.=“”.”|
"." | 
"." | 
"." | 
"." | 
"." | 
"." | 
"." | 
"." | 
"." | 
"." | 
"."
";
$Calendar.=''。\n';
提前谢谢

编辑:

我应该首先提到这个…只需要使用PHP

谢谢。

日历功能:


首先,您必须编写一个日历例程,其中包含$year和$month参数,并绘制一个月历。

好的。这里有一些提示可以从这里开始

正如我上面所说的,您必须为当前月份制作一个HTML日历。 从打印日期开始<代码>$num=日期(“t”)将给您提供天数。 因此,我希望您可以使用
for
循环,从1到$num,在单独的
标记中打印每个数字

接下来,尝试在7天内打破该列表。你可以用计数器来做这个。每次迭代都要增加它,当它达到7时,添加
以断开一行

最后。您必须将此列表与本周开始对齐<代码>日期(“w”)将帮助您完成此操作


你能做到吗

如果我有完整的代码,而不是我需要帮助的那部分表行,可能会更清楚。我已经创建了日历。我只是想在日历中添加额外的行,我可以单击该行按年份和月份打开新日历

如果您可以在浏览器上打开此php,您会注意到日历下面的三列链接。
左栏是从当前显示的年份打开上一年的链接。
右栏是从当前显示的年份中打开的明年链接。 中柱是从1月到12月的每个月的链接,无论单击哪个月,它都将从“当前”显示的年份打开该月日历

我希望这更清楚。我对任何困惑表示歉意

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>test</title>
<link rel="stylesheet" type="text/css" href="calendar.css" />
</head>
<body><center>
<?php
$date = time(); 

$Month = date('m', $date); 
$Day = date('d', $date); 
$Year = date('Y', $date);

/*  Calendar layout*/
function calendar_layout($month,$day,$year)
{

/*  This checkdate function displays "bool(true)" in the web page, so I commented out  */
//  var_dump(checkdate($month,$day,$year));

$MonthArray = array("January ","February ","March ","April ","May ","June ","July ","August ","September ","October ","Novembe r","December ");
$ThisMonth = $MonthArray[$month-1];

/*  Creates table for calendar  */
$Calendar = '<table border="1" cellpadding="5">';
$Header = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

/*  Creates the first row print the Month and Year of this calendar  */
$Calendar.= '<tr><td colspan="7">';
$Calendar.= '<div class="largewords">'.$ThisMonth.''.$year.'</div>';
$Calendar.= '</td></tr>';

/*  Creates the second row for Week days and print the week days header  */
$Calendar.= '<tr>
               <td class="weekdays">'.implode('</td><td class="weekdays">',$Header).'</td>
             </tr>';

/*  Finds out and set how many blank days before 1st day  */
$FirstDay = mktime(0,0,0,$month, 1, $year);  
$DayOfWeek = date('D', $FirstDay);
switch($DayOfWeek){
case "Sun": $BlankDays = 0; break;
case "Mon": $BlankDays = 1; break;
case "Tue": $BlankDays = 2; break;
case "Wed": $BlankDays = 3; break;
case "Thu": $BlankDays = 4; break;
case "Fri": $BlankDays = 5; break;
case "Sat": $BlankDays = 6; break;
}   

/*  Finds out how many total days this month  */
$DayInMonth = date('t',mktime(0,0,0,$month,1,$year));
$DayCounter = 0;

/*  Creates the second row for first week  */
$Calendar.= '<tr>';

/*  Prints the blank spaces before day 1  */
while($DayCounter < $BlankDays)
{
  $Calendar.= '<td>&nbsp;</td>';
  $DayCounter++;
}

/*  Starts printing dates  */
for($PrintDay = 1; $PrintDay <= $DayInMonth; $PrintDay++):
  $Calendar.= '<td class="eachday">';
  $Calendar.= '<div class="numericdays">'.$PrintDay.'</div>';
  $Calendar.= str_repeat('<p>&nbsp;</p>',2);

  $Calendar.= '</td>';
  if($BlankDays == 6):
    $Calendar.= '</tr>';
    if(($DayCounter+1) != $DayInMonth):
      $Calendar.= '<tr>';
    endif;
    $BlankDays = -1;
    $DayInWeek = 0;
  endif;
  $DayInWeek++; $BlankDays++; $DayCounter++;
endfor;

/*  Prints blank spaces after the last day of the month  */
if($DayInWeek < 8):
  for($x = 1; $x <= (8 - $DayInWeek); $x++):
    $Calendar.= '<td>&nbsp;</td>';
  endfor;
endif;


/*  Bottom row - links for other years and months  */

$LastYear = getDate(mktime(0, 0, 0, $month, 1, $year-1));
$ThisYear = getDate(mktime(0, 0, 0, $month, 1, $year));
$NextYear = getDate(mktime(0, 0, 0, $month, 1, $year+1));

$LastY = $LastYear["year"];
$ThisY = $ThisYear["year"];
$NextY = $NextYear["year"];

/*  Initializing the years range from 1970 to 2038  */
$MinYear = date("Y",mktime(0,0,0,1,1,1970));
$MaxYear = date("Y",mktime(0,0,0,1,1,2038));

$Calendar.= "</tr><tr><td>"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=" . $LastYear["year"] ."\"> $LastY </a></td>\n";
$Calendar.= "<td colspan=\"5\">"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[0] ."\">Jan.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[1] ."\">Feb.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[2] ."\">Mar.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[3] ."\">Apr.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[4] ."\">May</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[5] ."\">Jun.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[6] ."\">Jul.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[7] ."\">Aug.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[8] ."\">Sep.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[9] ."\">Oct.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[10] ."\">Nov.</a> | 
                               "."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[11] ."\">Dec.</a>
              </td>";
$Calendar.= "<td>"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=" . $NextYear["year"] ."\"> $NextY </a></td>\n";
}


/*  Close the table  */
$Calendar.= '</tr></table>';

return $Calendar;

}

echo '<a href="index.php">Today</a>', ' is: ', date('l, F jS Y');
echo "<br />";
echo "<br />";

echo calendar_layout("$Month","$Day","$Year");

?> 

</center>
</body>
</html>

现在的问题是…如何找出语法并将其应用于我的原始代码?

您可以做什么?坐下来写那个程序就行了。问题是什么?谢谢Leo的链接。我要读点书。弹片上校,我的问题很简单。如果您阅读了我上面的示例代码,我已经解释了我希望这段代码做什么。同样,作为PHP新手,我只是使用我简单的编程知识来创建代码。对你们中的一些人来说,这可能是一块蛋糕,但如果你只是让我坐下来写那个程序,那对我是没有帮助的(再次,我真的很感谢那些已经并将提供一些明智建议的人。谢谢。@Ray此链接不会对您有太多帮助。不要责怪答案,但请查看您的问题,内容广泛且不清楚。
if(isset($_GET["Year"]))
{
  use local system's year
}
else
{
  $Year = $_GET["Year"]
}