質問編集履歴
2
エラー行にコメントを挿入しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
上記のエラーメッセージが出ている行は
|
14
14
|
|
15
|
-
$d
|
15
|
+
$db->fetch_assoc();
|
16
16
|
|
17
17
|
となっており、
|
18
18
|
|
@@ -88,54 +88,54 @@
|
|
88
88
|
|
89
89
|
$result=$db->query("select count(*) from reserveslot where date>={$row["date"]}");
|
90
90
|
|
91
|
+
$row=$result->fetch_assoc(); // エラー行
|
92
|
+
|
93
|
+
if($row["count"]==0){
|
94
|
+
|
95
|
+
$result=$db->query("select * from today");
|
96
|
+
|
91
97
|
$row=$result->fetch_assoc();
|
92
98
|
|
99
|
+
$time=(int)$row["date"];
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
$db->query("insert into reserve_info (date) values({$row["date"]})");
|
104
|
+
|
105
|
+
print $db->error;
|
106
|
+
|
107
|
+
for($i=0;$i<6;$i++){
|
108
|
+
|
109
|
+
$db->query("insert into reserveslot (date) values('{$time}')");
|
110
|
+
|
111
|
+
$time=$time+86400;
|
112
|
+
|
113
|
+
print $db->error;
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
if($row["count"]!=0&&$row["count"]<7){
|
120
|
+
|
93
|
-
i
|
121
|
+
$count=(int)$row["count"];
|
122
|
+
|
94
|
-
|
123
|
+
$count=7-$count;
|
124
|
+
|
95
|
-
$result=$db->query("select * from today");
|
125
|
+
$result=$db->query("select * from reserveslot order by date desc order by date desc limit 1");
|
126
|
+
|
127
|
+
print $db->error;
|
96
128
|
|
97
129
|
$row=$result->fetch_assoc();
|
98
130
|
|
99
131
|
$time=(int)$row["date"];
|
100
132
|
|
101
|
-
|
102
|
-
|
103
|
-
$db->query("insert into reserve_info (date) values({$row["date"]})");
|
104
|
-
|
105
|
-
print $db->error;
|
106
|
-
|
107
|
-
for($i=0;$i<
|
133
|
+
for($i=0;$i<$count;$i++){
|
134
|
+
|
135
|
+
$time=$time+86400;
|
108
136
|
|
109
137
|
$db->query("insert into reserveslot (date) values('{$time}')");
|
110
138
|
|
111
|
-
$time=$time+86400;
|
112
|
-
|
113
|
-
print $db->error;
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
}
|
118
|
-
|
119
|
-
if($row["count"]!=0&&$row["count"]<7){
|
120
|
-
|
121
|
-
$count=(int)$row["count"];
|
122
|
-
|
123
|
-
$count=7-$count;
|
124
|
-
|
125
|
-
$result=$db->query("select * from reserveslot order by date desc order by date desc limit 1");
|
126
|
-
|
127
|
-
print $db->error;
|
128
|
-
|
129
|
-
$row=$result->fetch_assoc();
|
130
|
-
|
131
|
-
$time=(int)$row["date"];
|
132
|
-
|
133
|
-
for($i=0;$i<$count;$i++){
|
134
|
-
|
135
|
-
$time=$time+86400;
|
136
|
-
|
137
|
-
$db->query("insert into reserveslot (date) values('{$time}')");
|
138
|
-
|
139
139
|
print $db->error;
|
140
140
|
|
141
141
|
}
|
1
コメント欄に書いたソースコードをここに書き直しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -72,9 +72,175 @@
|
|
72
72
|
|
73
73
|
|
74
74
|
|
75
|
+
function product_reserve_time(){
|
76
|
+
|
77
|
+
$db=new mysqli("localhost","username","password","dbname");
|
78
|
+
|
79
|
+
$db->set_charset("sjis");
|
80
|
+
|
81
|
+
$result=$db->query("select* from today");
|
82
|
+
|
83
|
+
print $db->error;
|
84
|
+
|
85
|
+
$row=$result->fetch_assoc();
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
$result=$db->query("select count(*) from reserveslot where date>={$row["date"]}");
|
90
|
+
|
91
|
+
$row=$result->fetch_assoc();
|
92
|
+
|
93
|
+
if($row["count"]==0){
|
94
|
+
|
95
|
+
$result=$db->query("select * from today");
|
96
|
+
|
97
|
+
$row=$result->fetch_assoc();
|
98
|
+
|
99
|
+
$time=(int)$row["date"];
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
$db->query("insert into reserve_info (date) values({$row["date"]})");
|
104
|
+
|
105
|
+
print $db->error;
|
106
|
+
|
107
|
+
for($i=0;$i<6;$i++){
|
108
|
+
|
109
|
+
$db->query("insert into reserveslot (date) values('{$time}')");
|
110
|
+
|
111
|
+
$time=$time+86400;
|
112
|
+
|
113
|
+
print $db->error;
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
if($row["count"]!=0&&$row["count"]<7){
|
120
|
+
|
121
|
+
$count=(int)$row["count"];
|
122
|
+
|
123
|
+
$count=7-$count;
|
124
|
+
|
125
|
+
$result=$db->query("select * from reserveslot order by date desc order by date desc limit 1");
|
126
|
+
|
127
|
+
print $db->error;
|
128
|
+
|
129
|
+
$row=$result->fetch_assoc();
|
130
|
+
|
131
|
+
$time=(int)$row["date"];
|
132
|
+
|
133
|
+
for($i=0;$i<$count;$i++){
|
134
|
+
|
135
|
+
$time=$time+86400;
|
136
|
+
|
137
|
+
$db->query("insert into reserveslot (date) values('{$time}')");
|
138
|
+
|
139
|
+
print $db->error;
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
$result=$db->query("select * from reserveslot where date>=(select date from today) limit 7");
|
148
|
+
|
149
|
+
print $db->error;
|
150
|
+
|
151
|
+
while($row=$result->fetch_assoc()) {
|
152
|
+
|
153
|
+
printf("<input type=\"radio\" name=\"date\" value=\"%s\">%s月%s日",$row["date"],idate("m",$row["date"]),idate("d",$row["date"]));
|
154
|
+
|
155
|
+
printf("<select name=\"%s\"><option>----</option>",$row["date"]);
|
156
|
+
|
157
|
+
if($row["rs1"]==0) print "<option value=\"1\">19:00</option>";
|
158
|
+
|
159
|
+
if($row["rs2"]==0) print "<option value=\"2\">20:30</option>";
|
160
|
+
|
161
|
+
if($row["rst3"]==0) print "<option value=\"3\">22:00</option>";
|
162
|
+
|
163
|
+
if($row["rt4"]==0) print "<option value=\"4\">23:30</option>";
|
164
|
+
|
165
|
+
if($row["rs5"]==0) print "<option value=\"5\">25:00</option>";
|
166
|
+
|
167
|
+
if($row["rs6"]==0) print "<option value=\"6\">26:30</option>";
|
168
|
+
|
169
|
+
if($row["rs7"]==0) print "<option value=\"7\">28:00</option>";
|
170
|
+
|
171
|
+
print "</select><br><br>";
|
172
|
+
|
173
|
+
}
|
174
|
+
|
175
|
+
$db->close();
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
function updtrs(){
|
182
|
+
|
183
|
+
$query="update table reserveslot set ";
|
184
|
+
|
185
|
+
switch($_SESSION["time"]){
|
186
|
+
|
187
|
+
case "1":
|
188
|
+
|
189
|
+
$query.="rs1=1 ";
|
190
|
+
|
191
|
+
break;
|
192
|
+
|
193
|
+
case "2":
|
194
|
+
|
195
|
+
$query.="rs2=1 ";
|
196
|
+
|
197
|
+
break;
|
198
|
+
|
199
|
+
case "3":
|
200
|
+
|
201
|
+
$query.="rs3=1";
|
202
|
+
|
203
|
+
break;
|
204
|
+
|
205
|
+
case "4":
|
206
|
+
|
207
|
+
$query.="rs4=1 ";
|
208
|
+
|
209
|
+
break;
|
210
|
+
|
211
|
+
case "5":
|
212
|
+
|
213
|
+
$query.="rs5=1 ";
|
214
|
+
|
215
|
+
break;
|
216
|
+
|
217
|
+
case "6":
|
218
|
+
|
219
|
+
$query.="rs6=1 ";
|
220
|
+
|
221
|
+
break;
|
222
|
+
|
223
|
+
case "7":
|
224
|
+
|
225
|
+
$query.="rs7=1 ";
|
226
|
+
|
227
|
+
break;
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
$query.="where date='".$_SESSION["date"]."'";
|
232
|
+
|
233
|
+
$db=new mysqli("localhost","username","password","dbname");
|
234
|
+
|
235
|
+
$db->query("{$query}");
|
236
|
+
|
237
|
+
$db->close();
|
238
|
+
|
239
|
+
}
|
240
|
+
|
75
241
|
```
|
76
242
|
|
77
|
-
|
243
|
+
最初からこのようにすればよかったかもしれませんね。
|
78
244
|
|
79
245
|
### 試したこと
|
80
246
|
|