<html> <?php /*Calendar,By [email protected]*/ /*2005-2-21*/ /*I'll write my own calendar here*/ $week=array("Su","Mo","Tu","We","Th","Fr","Sa"); $this_year=date("Y"); $this_month=date("n"); $this_day=date("j"); ?> <div align="center"> <form action="<?php echo $SCRIPT_NAME ?>" method="post"> Year:<input type="text" name="s_year" maxlength="4" size="5" value="/<?php echo $this_year;?>> Month:<input type="text" name="s_month" maxlength="2" size="3" value=<?php echo $this_month;?>> <input type="submit" name="ok" value="/Go!"> </form> <?php $year=$_POST[s_year]; $month=$_POST[s_month]; echo $year."-".$month; ?> <table width="20%" height="160" border="1"> <?php /*Print the calendar*/ /*we need to know what the date of the first day of selected month is.*/ /*print a whole week head*/ for ($wa=0;$wa<=6;$wa++) { ?> <td><font color=""#000080" ><?php echo $week[$wa];?></font></td> <?php } /*print all days*/ for($day=1;$day<=date("t",mktime(0,0,0,$month,1,$year)/*get the days number of this month*/);$day++) { if ($day == 1) { /*form begin*/ ?> <tr> <?php for ($bk=0;$bk<date("w",mktime(0,0,0,$month,1,$year));$bk++)/*the first day of the month to a certain date,print blank before it*/ { ?> <td></td> <?php } } if ( strcmp(date("w",mktime(0,0,0,$month,$day,$year)),0) == 0) { /*if the day is Sun. ,then start a new line*/ ?> <tr> <td align=center><font color="#000080" ><a href="" target=""><?php echo $day;?></a></font></td> <?php } else { ?> <td align=center><font color="#000080" ><a href="" target=""><?php echo $day;?></a></font></td> <?php } } ?> </table> </div> </html> |