質問編集履歴

1

アドバイスを受け、更新致しました。

2015/07/10 08:11

投稿

yutaishikawa_
yutaishikawa_

スコア58

test CHANGED
File without changes
test CHANGED
@@ -131,3 +131,125 @@
131
131
  </html>
132
132
 
133
133
  ```
134
+
135
+
136
+
137
+
138
+
139
+ 追記:皆様ご回答ありがとうございます。まとめてみたところ、以下のような記述となりました。
140
+
141
+ ですが、表示はされません。
142
+
143
+
144
+
145
+
146
+
147
+ ```lang-PHP
148
+
149
+ <?php
150
+
151
+ require_once('dbconnect.php');
152
+
153
+ // 年月日のパラメータを取得する。
154
+
155
+ $ymd = isset($_GET['ymd']) ? $_GET['ymd'] : date("Y-m-d");
156
+
157
+ // タスクの配列を準備
158
+
159
+ $task = "";
160
+
161
+ $taskData = array();
162
+
163
+ // PHP->MySQLtable
164
+
165
+ // タスクのパラメータを送れるようにする。
166
+
167
+ $query = $mysqli->query(" SELECT * FROM tasks WHERE task_date = '$ymd' ");
168
+
169
+ // エラー処理
170
+
171
+ if (!$query) {
172
+
173
+ die('クエリーが失敗しました。'.mysql_error());
174
+
175
+ }
176
+
177
+ while ($row[] = $query->fetch_assoc()) {
178
+
179
+ // 各メンバ取得
180
+
181
+ $taskData[] = array(
182
+
183
+ 'id'=>$row['id'],
184
+
185
+ 'title'=>$row['title'],
186
+
187
+ 'task_date'=>$row['task_date'],
188
+
189
+ 'place'=>$row['place'],
190
+
191
+ 'memo'=>$row['memo']
192
+
193
+ );
194
+
195
+ // タスクを表示形式に設定
196
+
197
+ $task .= "<td>".$row."</td>";
198
+
199
+ }
200
+
201
+ ?>
202
+
203
+ <!DOCTYPE html>
204
+
205
+ <html lang="ja">
206
+
207
+ <meta charset="utf-8">
208
+
209
+ <title>Today | タスク一覧</title>
210
+
211
+ <table border="1">
212
+
213
+ <thead>
214
+
215
+ <tr>
216
+
217
+ <th>タイトル</th>
218
+
219
+ <th>日時</th>
220
+
221
+ <th>場所</th>
222
+
223
+ <th>メモ</th>
224
+
225
+ </tr>
226
+
227
+ </thead>
228
+
229
+ <tbody>
230
+
231
+ <?php foreach ($taskData as $row): ?>
232
+
233
+ <tr>
234
+
235
+ <td><?= htmlspecialchars($row['title']) ?></td>
236
+
237
+ <td><?= htmlspecialchars($row['task_date']) ?></td>
238
+
239
+ <td><?= htmlspecialchars($row['place']) ?></td>
240
+
241
+ <td><?= htmlspecialchars($row['memo']) ?></td>
242
+
243
+ </tr>
244
+
245
+ <?php endforeach; ?>
246
+
247
+ </tbody>
248
+
249
+ </table>
250
+
251
+ <p><a href="index.php">追加画面に戻る</a></p>
252
+
253
+ </html>
254
+
255
+ ```