PHP Output Calendar Table code example _php Tutorial

Source: Internet
Author: User

PHP Output Calendar Table code example


This article mainly introduces the PHP output calendar Table code example, this article directly gives code examples, the need for friends can refer to the following

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21st

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

Calendar table

$MONTH = Array ("All", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

$enMONTH = Array ("January", "February", "Marcy", "April", "may", "June", "July", "August", "September", "October", "N Ovember "," December ");

$WEEK = Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

$BACKCOLOR = Array ("#FFC", "#FFF", "#9F6", "#FFC", "#6F0", "#6F6", "#F90", "#F06", "#F00", "#FC3", "#FF6", "#F9 9 ");

function Printmon ($year, $mon)

{

Date_default_timezone_set ("Asia/shanghai");

Global $MONTH;

Global $enMONTH;

Global $WEEK;

Global $BACKCOLOR;

$startdate =strtotime ("1 $enMONTH [$mon] $year"); Gets the date of the query

$enddate = Strtotime ("+1 month", $startdate); Gets the start date for the next one months as a deadline for the monthly calendar output

$theDate = getdate ($startdate); Convert date to string format

$color = $BACKCOLOR [$mon]; Set the background color for a month calendar

Echo ("

$ym = $year. "Year". $MONTH [$mon];

Echo ("

Echo ("

for ($i =0; $i <7; $i + +)//output Day of the week

{

Echo ("

}

Echo ("

$theWeek = $theDate [wday];//determines the day of the week

for ($i =0; $i <6; $i + +)

{

Echo ("

for ($j =0; $j <7; $j + +)

{

Echo ("

}

Echo ("

if ($startdate = = $enddate)//If the full date has been output, end the loop

{

$i = 6;

}

}

Echo ("

?>

$month = $_post[' mymonth ');

if (Is_numeric ($year) && $year >= 1970 && $year <2038)

{

if (Is_numeric ($month) && $month >= 1 && $month <=12)

{

Printmon ($year, $month);

}

else if ($month! = NULL)

{

Echo ("Month is wrong".) "
");

}

}

else if ($year! = NULL)

{

Echo ("Wrong Year".) "
");

}

?>

}

$year = $_post[' myyear ');

"); "); "); "); "); "); "); ");

$ym

");

Echo ("

$WEEK [$i]

");

Echo ("

");

if ($startdate < $enddate && $theWeek = = $j)//Output the date to the corresponding day of the week, and be careful not to exceed this month's date

{

$theDay = $theDate [Mday];

Echo ("

$theDay

");

$startdate = Strtotime ("+1 Day", $startdate); Date moved forward 1 days

$theDate = getdate ($startdate);//Update date

$theWeek = ($theWeek + 1)% 7;//Update week

}

Echo ("

http://www.bkjia.com/PHPjc/975128.html www.bkjia.com true http://www.bkjia.com/PHPjc/975128.html techarticle PHP Output Calendar Table Code example this article mainly introduces the PHP output calendar Table code example, this article directly give code examples, the need for friends to refer to the next? 1 2 3 4 5 6 7 8 9 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.