質問編集履歴
3
プレースホルダーを:month_selectedに修正、POSTされた数値が1桁の月の場合、0詰めされるように修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,11 +24,11 @@
|
|
24
24
|
|
25
25
|
$sql = 'SELECT date, menu FROM menu
|
26
26
|
|
27
|
-
WHERE (DATE_FORMAT(date, "%m") = ":month
|
27
|
+
WHERE (DATE_FORMAT(date, "%m") = ":month_selected")
|
28
28
|
|
29
29
|
';
|
30
30
|
|
31
|
-
$data = array(':month
|
31
|
+
$data = array(':month_selected' => $_SESSION['month-selected']);
|
32
32
|
|
33
33
|
$stmt = queryPost($dbh, $sql, $data);
|
34
34
|
|
@@ -106,7 +106,7 @@
|
|
106
106
|
|
107
107
|
foreach ($month as $key){ ;?>
|
108
108
|
|
109
|
-
<option value="<?php echo $key; ?>"><?php echo $key; ?></option>
|
109
|
+
<option value="<?php echo printf("%02d", $key); ?>"><?php echo $key; ?></option>
|
110
110
|
|
111
111
|
<?php
|
112
112
|
|
2
文言の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -84,7 +84,7 @@
|
|
84
84
|
|
85
85
|
}else{
|
86
86
|
|
87
|
-
debug('
|
87
|
+
debug('DBには接続できました');
|
88
88
|
|
89
89
|
return $stmt;
|
90
90
|
|
1
queryPost()の追加、<option>の'>'抜けの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -62,6 +62,40 @@
|
|
62
62
|
|
63
63
|
```
|
64
64
|
|
65
|
+
|
66
|
+
|
67
|
+
上記関数内で使用しているqueryPost()は以下の通りです。
|
68
|
+
|
69
|
+
```PHP
|
70
|
+
|
71
|
+
function queryPost($dbh, $sql, $data){
|
72
|
+
|
73
|
+
$stmt = $dbh->prepare($sql);
|
74
|
+
|
75
|
+
if(!$stmt->execute($data)){
|
76
|
+
|
77
|
+
debug('クエリに失敗しました');
|
78
|
+
|
79
|
+
debug('失敗したSQL:'.print_r($stmt, true));
|
80
|
+
|
81
|
+
$err_msg['common'] = MSG07;
|
82
|
+
|
83
|
+
return 0;
|
84
|
+
|
85
|
+
}else{
|
86
|
+
|
87
|
+
debug('基本的なDBには接続できたよ');
|
88
|
+
|
89
|
+
return $stmt;
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
```
|
96
|
+
|
97
|
+
|
98
|
+
|
65
99
|
```HTML
|
66
100
|
|
67
101
|
<select name="month-selected">
|
@@ -72,7 +106,7 @@
|
|
72
106
|
|
73
107
|
foreach ($month as $key){ ;?>
|
74
108
|
|
75
|
-
<option value="<?php echo $key; ?>"
|
109
|
+
<option value="<?php echo $key; ?>"><?php echo $key; ?></option>
|
76
110
|
|
77
111
|
<?php
|
78
112
|
|