加一句,if($curr_date == date("%Y-%m-%d"))
$date_color = "yellow";
同理if (week="6" || week = "0")
$week_color = "red";

解决方案 »

  1.   

    改成这样:<?php 
    /* PHP自动生成月历代码共享
    Function Written by Nelson Neoh @3/2004. 
    For those who wants to utilize this code, please do not remove this re. 
    If you have done any enhancement to this code, please post the copy at http://www.dev-club.com PHP board. Thank you. Function usage: calendar(Month,Year) 
    */ //function calendar($MM,$YYYY){ 
    if($MM=="") $MM = date("m"); 
    if($YYYY=="") $YYYY = date("Y"); 
    if($YY=="") $YY = date("Y"); 
    if(checkdate($MM,1,$YYYY)){ 
    $stringDate = strftime("%d %b %Y",mktime (0,0,0,$MM,1,$YYYY)); 
    $days = strftime("%d",mktime (0,0,0,$MM+1,0,$YYYY)); 
    $firstDay = strftime("%w",mktime (0,0,0,$MM,1,$YYYY)); 
    $lastDay = strftime("%w",mktime (0,0,0,$MM,$days,$YYYY)); 
    $printDays = $days; 
    $preMonth = strftime("%m",mktime (0,0,0,$MM-1,1,$YYYY)); 
    $preYear = strftime("%Y",mktime (0,0,0,$MM-1,1,$YYYY)); 
    $nextMonth = strftime("%m",mktime (0,0,0,$MM+1,1,$YYYY)); 
    $nextYear = strftime("%Y",mktime (0,0,0,$MM+1,1,$YYYY)); 
    print("<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\" width=220>"); 
    print("<tr><th valign=\"top\"><a href=\"".$_SERVER['PHP_SELF']."?NB=".$_GET["NB"]."&MM=".$preMonth."&YY=".$preYear."\"><img src=images/leftarrow.png border=0></a></th>"); 
    print("<th colspan=\"5\"><font size=2>".strftime("%Y年%m月",mktime (0,0,0,$MM,1,$YYYY))."</font></th>"); 
    print("<th valign=\"top\"><a href=\"".$_SERVER['PHP_SELF']."?NB=".$_GET["NB"]."&MM=".$nextMonth."&YY=".$nextYear."\"><img src=images/rightarrow.png border=0></a></th></tr>"); 
    print("<tr style=\"font-family: Verdana; font-size:x-small\">"); 
    print("<th>日</th><th>一</th><th>二</th><th>三</th><th>四</th><th>五</th><th>六</th></tr>"); $currentDays = 1; 
    $b = 5;
    for($a=1;$a<=$b;$a++){ 
    print("<tr align=\"left\" valign=\"top\" style=\"font-family: Verdana; font-size:x-small\">"); 
    $diffDays = $firstDay-$lastDay; 
    if($firstDay>$lastDay && $currentDays ==1 && ($diffDays<>1)){ 
    for($x=$lastDay;$x>=0;$x--){ 
       $b = 6;
    print("<td align='center' width=14%>&nbsp;</a></td>"); 


    for($z=1;$z<$firstDay-$lastDay;$z++){ 
    print("<td align='center' width=14%>&nbsp;</td>"); 
    }  for($y=$firstDay;$y<7;$y++){ 
    print("<td align='center' width=14%><a href=reserve.php?date=$YY$MM$currentDays>$currentDays</a></td>"); 
    $currentDays++; 

    } elseif($firstDay!=0 && $currentDays==1){ 
    for($z=1;$z<=$firstDay;$z++){ 
    print("<td align='center' width=14%>&nbsp;</td>"); 
    }  for($y=$firstDay;$y<7;$y++){ 
    print("<td align='center' width=14%><a href=reserve.php?date=$YY$MM$currentDays>$currentDays</a></td>"); 
    $currentDays++; 


    } else { 

    for($u=1;$u<=7 && $currentDays<=$days;$u++){ 
    if ($u==1) 
    print("<td align='center' width=14%><a href=reserve.php?date=$YY$MM$currentDays><font color='#FF0000'>$currentDays</font></a></td>"); 
    else
    print("<td align='center' width=14%><a href=reserve.php?date=$YY$MM$currentDays>$currentDays</a></td>"); 
    $currentDays++; 
    }  while($u++ <=7)
      print("<td>&nbsp;</td>"); 

    print("</tr>"); 

    print("</table>"); 

     
    ?>
      

  2.   

    print("<tr style=\"font-family: Verdana; font-size:x-small\">"); 就在style里改
      

  3.   

    <?php 
    /* PHP自动生成月历代码共享
    Function Written by Nelson Neoh @3/2004. 
    For those who wants to utilize this code, please do not remove this re. 
    If you have done any enhancement to this code, please post the copy at http://www.dev-club.com PHP board. Thank you. Function usage: calendar(Month,Year) 
    */ //function calendar($MM,$YYYY){ 
    if($MM=="") $MM = date("m"); 
    if($YYYY=="") $YYYY = date("Y"); 
    if($YY=="") $YY = date("Y"); 
    if(checkdate($MM,1,$YYYY)){ 
    $stringDate = strftime("%d %b %Y",mktime (0,0,0,$MM,1,$YYYY)); 
    $days = strftime("%d",mktime (0,0,0,$MM+1,0,$YYYY)); 
    $firstDay = strftime("%w",mktime (0,0,0,$MM,1,$YYYY)); 
    $lastDay = strftime("%w",mktime (0,0,0,$MM,$days,$YYYY)); 
    $printDays = $days; 
    $preMonth = strftime("%m",mktime (0,0,0,$MM-1,1,$YYYY)); 
    $preYear = strftime("%Y",mktime (0,0,0,$MM-1,1,$YYYY)); 
    $nextMonth = strftime("%m",mktime (0,0,0,$MM+1,1,$YYYY)); 
    $nextYear = strftime("%Y",mktime (0,0,0,$MM+1,1,$YYYY)); 
    print("<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\" width=220>"); 
    print("<tr><th valign=\"top\"><a href=\"".$_SERVER['PHP_SELF']."?NB=".$_GET["NB"]."&MM=".$preMonth."&YY=".$preYear."\"><img src=images/leftarrow.png border=0></a></th>"); 
    print("<th colspan=\"5\"><font size=2>".strftime("%Y年%m月",mktime (0,0,0,$MM,1,$YYYY))."</font></th>"); 
    print("<th valign=\"top\"><a href=\"".$_SERVER['PHP_SELF']."?NB=".$_GET["NB"]."&MM=".$nextMonth."&YY=".$nextYear."\"><img src=images/rightarrow.png border=0></a></th></tr>"); 
    print("<tr style=\"font-family: Verdana; font-size:x-small\">"); 
    print("<th>日</th><th>一</th><th>二</th><th>三</th><th>四</th><th>五</th><th>六</th></tr>"); $currentDays = 1; 
    $b = 5;
    for($a=1;$a<=$b;$a++){ 
    print("<tr align=\"left\" valign=\"top\" style=\"font-family: Verdana; font-size:x-small\">"); 
    $diffDays = $firstDay-$lastDay; 
    if($firstDay>$lastDay && $currentDays ==1 && ($diffDays<>1)){ 
    for($x=$lastDay;$x>=0;$x--){ 
       $b = 6;
    print("<td align='center' width=14%>&nbsp;</a></td>"); 


    for($z=1;$z<$firstDay-$lastDay;$z++){ 
    print("<td align='center' width=14%>&nbsp;</td>"); 
    }  for($y=$firstDay;$y<7;$y++){ 
    print("<td align='center' width=14%><a href=reserve.php?date=$YY$MM$currentDays>$currentDays</a></td>"); 
    $currentDays++; 

    } elseif($firstDay!=0 && $currentDays==1){ 
    for($z=1;$z<=$firstDay;$z++){ 
    print("<td align='center' width=14%>&nbsp;</td>"); 
    }  for($y=$firstDay;$y<7;$y++){ 
    print("<td align='center' width=14%><a href=reserve.php?date=$YY$MM$currentDays>$currentDays</a></td>"); 
    $currentDays++; 


    } else { 

    for($u=1;$u<=7 && $currentDays<=$days;$u++){ 
    if ($u==1) 
    print("<td align='center' width=14%><a href=reserve.php?date=$YY$MM$currentDays><font color='#FF0000'>$currentDays</font></a></td>"); 
    else
    print("<td align='center' width=14%><a href=reserve.php?date=$YY$MM$currentDays>$currentDays</a></td>"); 
    $currentDays++; 
    }  while($u++ <=7)
      print("<td>&nbsp;</td>"); 

    print("</tr>"); 

    print("</table>"); 

     
    ?>  
      

  4.   

    Jah1919,当前日期是黄色没有!!!
      

  5.   

    //function calendar($MM,$YYYY){ 这是什么意思?
      

  6.   

    麻烦
    <?//日历 
    $month = date("n"); 
    $year = date("Y");
    $weekArray = array("<font color=red>日</font>","一","二","三","四","五","六"); 
    ?> 
    <STYLE> 
    .cal_table{font-family:Tahoma,Georgia; font-size:12px;  border-collapse:collapse;} 
    .cal_td{border-width:1; border-color:#cccccc; border-style:solid;} 
    </STYLE> 
    <table width=210 class=cal_table>
     <tr><td align=center colspan=7 bgcolor=#bbbbff class=cal_td>
     <?=$year."年".$month."月"?>
     </td></tr>
     <tr> 
    <?
    foreach($weekArray as $week) echo "<td align=center class=cal_td><b>".$week."</b></td>"; 
    ?> 
     </tr> 
    <?
    $n = 0; 
    $w = date("w" , mktime(0 , 0 , 0 , $month , 1 , $year));
    for($x = 0 ; $x < $w ; $x ++) {   //输出首日前表格 
    echo ($x == 0) ? "<tr>" : ""; 
    echo "<td width=30 class=cal_td>&nbsp;</td>"; 
    $n ++; 

    for($day = 1 ; $day < 32; $day ++) {   //输出日期 
    if(!checkdate($month , $day , $year)) break; 
    echo ($n==0)?"<tr>":""; 
    $color     = ($day == date("j"))? "yellow" : "white"; 
    $fontColor = ($n==0)? "red" : "#888888"; 
    echo "<td align=center width=30 bgcolor=".$color." class=cal_td><font color=".$fontColor.">".$day."</font></td>"; 
    $n ++; 
    if($n == 7) { 
    echo "</tr>"; 
    $n = 0; 

    }
    while($n < 7 && $n != 0) {   //输出末日后表格 
    echo "<td width=30 class=cal_td>&nbsp;</td>"; 
    $n++; 

    if($n == 7) echo "</tr>"; 
    ?> 
    </table>
      

  7.   

    http://urg.vicp.net/calendar.php别人的够NB的
    http://urg.vicp.net/cale.php我的够垃圾的:
    <link href="corp.css" rel="stylesheet" type="text/css">
    <style type="text/css">
    td
    {font-size:12px;}
    </style>
    <script language="JavaScript">
    function tm(y,m,d)
    {
    if (d<10)
    {
    dd="0"+d
    }else
    {
    dd=d
    }
    if (m<10)
    {
    mm="0"+m
    }else
    {
    mm=m
    }
    tdt=y+""+mm+dd
    parent.form1.lookday.value=tdt
    parent.form1.submit()
    }
    </script>
    <?php 
    session_start();
    if (isset($HTTP_POST_VARS['year'])&&isset($HTTP_POST_VARS['month'])){
    $_SESSION['year']=$HTTP_POST_VARS['year'];
    $_SESSION['month']=$HTTP_POST_VARS['month'];
    }
    if (isset($HTTP_SESSION_VARS['year'])&&isset($HTTP_SESSION_VARS['month'])){
    $cur_year = $HTTP_SESSION_VARS['year'];
    $cur_month = $HTTP_SESSION_VARS['month'];
    }else
    {
    $cur_year=date("Y");
    $cur_month = date("m");
    }
    ?>
    <form name="form1" method="post">  <select name="year" id="year">
        <option value="2004" selected>2004</option>
    <?php 

      for ($i=2005;$i<2007;$i++)
      {
    if ($cur_year==$i) 
    {
    echo "\" selected>".$i."\n";
    }
    else
    {
    echo "\">".$i."\n";
    }
      }
      ?>
      </select>
      <select name="month" id="month" onChange="form1.submit();">
        <option value="1">1</option>
    <?php 
      for ($i=2;$i<13;$i++)
      {
      
      if ($cur_month==$i) 
    {
    echo "<option value=\"".$i."\" selected>".$i."\n";
    }
    else
    {
    echo "<option value=\"".$i."\">".$i."\n";
    }
      
      }
      ?>
      </select>
      
    </form><?php
    //当前月份第一天零时零分零秒的时间截
    $StartTimestamp = mktime(0,0,0,$cur_month,1,$cur_year);
    //得到当前月份的第一天是星期几,0忭示星期天?6忭示星期菱
    $FirstDayOfWeek = date('w',$StartTimestamp);//得到当前月份的天数
    $DaysOfMonth = date('t',$StartTimestamp);
    if (($FirstDayOfWeek)!="0"){
    for($i=1;$i<$FirstDayOfWeek;$i++){
    $day[] = '';
    $i;
    }
    }for($j=1;$j<=$DaysOfMonth;$j++){
        $day[] = $j;
    }echo "<table border=1 bordercolor=#FF0000>\n";
    echo "<tr>\n";
    echo "<td>一</td>\n";
    echo "<td>二</td>\n";
    echo "<td>三</td>\n";
    echo "<td>四</td>\n";
    echo "<td>五</td>\n";
    echo "<td>六</td>\n";
    echo "<td>日</td>\n";
    echo "</tr>\n";
    echo "<tr>\n";for($k=1;$k<count($day)+1;$k++){
    if ($cur_year==date("Y")&&$cur_month == date("m")&&$day[$k-1]==date("d"))
    {
    $dstr="<font color=00ff00>".$day[$k-1]."</font>";
    }else
    {
    $dstr=$day[$k-1];
    }
      
        if($k%7 == 0){
    echo "<td><font color=ff0000>".$dstr."</font></a></td>\n";
    echo "</tr><tr>\n";
        }else
    {
      echo "<td>".$dstr."</a></td>\n";
    }
    }echo "</tr>\n";
    echo "</table>\n";
    ?>