teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

誤字を修正いたしました。

2019/05/11 00:51

投稿

amaturePy
amaturePy

スコア131

title CHANGED
File without changes
body CHANGED
@@ -4,8 +4,7 @@
4
4
  調べては見たのですが、なかなか機能しないため、お力をお借りしたく質問させて頂いてます。
5
5
 
6
6
  ```PHP
7
- コード
8
- !DOCTYPE html>
7
+ <!DOCTYPE html>
9
8
  <html>
10
9
  <head>
11
10
  <title>Kento Calendar</title>

1

マークアップにコードを入れ直しました。申し訳ございませんでした。

2019/05/11 00:51

投稿

amaturePy
amaturePy

スコア131

title CHANGED
File without changes
body CHANGED
@@ -3,9 +3,9 @@
3
3
  ループ処理により年間分のカレンダー情報を表示と考えているのですが、そのような仕組みを作った機械がなく、
4
4
  調べては見たのですが、なかなか機能しないため、お力をお借りしたく質問させて頂いてます。
5
5
 
6
- ```ここに言語を入力
6
+ ```PHP
7
7
  コード
8
- ```<!DOCTYPE html>
8
+ !DOCTYPE html>
9
9
  <html>
10
10
  <head>
11
11
  <title>Kento Calendar</title>
@@ -18,16 +18,16 @@
18
18
  $now_month = date("m");
19
19
  $now_day = date("j");
20
20
  $weekday = array( "Sunday", "Monday", "Thuseday", "Wednesday", "Thursday", "Friday", "Saturday" );
21
- // 1日の曜日を数値で取得
21
+
22
22
  $fir_weekday = date( "w", mktime( 0, 0, 0, $now_month, 1 , $now_year ) );
23
23
  ///////////////////////////////////setting valuable
24
24
  echo '<table border="1" cellspacing="0" cellpadding="0" style="text-align:center;">';
25
25
  // 見出し部分<caption>タグ出力
26
26
  echo "<caption style=\"color:black; font-size:14px; padding:0px;\">"
27
27
  .$now_month."/".$now_year."
28
- </caption>\n";///////////////caption
28
+ </caption>\n";////////////////////////caption
29
29
 
30
- echo "<tr>\n";
30
+ echo "<tr>\n";
31
31
 
32
32
  $i = 0; // カウント値リセット
33
33
  while( $i <= 6 ){ // 曜日分ループ
@@ -97,20 +97,22 @@
97
97
  echo "</table>\n";
98
98
 
99
99
  ///////////////////////////////////////////////////////previous and next month
100
- for($now_month=0;$now_month<=12;$now_month++){
101
- break;
102
- }
103
- ?>
100
+ ?>
101
+
102
+ <?php
104
- <form action="previous_month.php" method="POST">
103
+ $ym = (isset($_GET["ym"]))? $_GET["ym"] : date("Ym");
105
- <input type="submit" name="previous_month" value="PreviousMonth">
104
+
106
- <input type="submit" name="next_month" value="NextMonth">
105
+ $lastmonth = date("Ym",strtotime($ym."01"." -1 month "));
106
+ $nextmonth = date("Ym",strtotime($ym."01"." +1 month "));
107
+
108
+ echo '<a href="ex5-2.php?ym='.$lastmonth.'">Last month</a>';
107
- </form>
109
+ echo "<br>";
110
+ echo '<a href="ex5-2.php?ym='.$nextmonth.'">Next month</a>';
111
+
112
+ $this_month_days = date("t",strtotime($ym."01"));//当月の日数を取得。
113
+ ?>
108
114
 
109
-
110
-
111
-
112
- </body>
115
+ </body>
113
- </html>
116
+ </html>
114
-
115
- コード
117
+
116
118
  ```