質問編集履歴
1
PHPのコードをコピペミスしていたので追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -176,20 +176,6 @@
|
|
176
176
|
|
177
177
|
|
178
178
|
|
179
|
-
|
180
|
-
|
181
|
-
$id = '';
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
$inputname = '';
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
$inputemail = '';
|
190
|
-
|
191
|
-
|
192
|
-
|
193
179
|
//エラー処理
|
194
180
|
|
195
181
|
if($flag == false){
|
@@ -198,29 +184,21 @@
|
|
198
184
|
|
199
185
|
}else{
|
200
186
|
|
201
|
-
//これだと最後のデータしかinputタグに挿入されない。
|
202
|
-
|
203
|
-
while ($result = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
204
|
-
|
205
|
-
$id = $result['id'];
|
206
|
-
|
207
|
-
$inputname .= $result['name'];
|
208
|
-
|
209
|
-
$inputemail .= $result['email'];
|
210
|
-
|
211
|
-
}
|
212
|
-
|
213
187
|
|
214
188
|
|
215
189
|
$result = $stmt->fetchAll();
|
216
190
|
|
217
|
-
|
191
|
+
//$resultからidの配列を取り出す
|
218
192
|
|
219
193
|
$id = array_column($result,'id');
|
220
194
|
|
221
|
-
|
195
|
+
//$resultからnameの配列を取り出す
|
196
|
+
|
222
|
-
|
197
|
+
$name = array_column($result,'name');
|
198
|
+
|
223
|
-
e
|
199
|
+
//$resultからemailの配列を取り出す
|
200
|
+
|
201
|
+
$email = array_column($result,'email');
|
224
202
|
|
225
203
|
|
226
204
|
|
@@ -232,6 +210,44 @@
|
|
232
210
|
|
233
211
|
|
234
212
|
|
213
|
+
<!DOCTYPE html>
|
214
|
+
|
215
|
+
<html lang="ja">
|
216
|
+
|
217
|
+
<head>
|
218
|
+
|
219
|
+
<meta charset="UTF-8">
|
220
|
+
|
221
|
+
<title>Document</title>
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
</style>
|
226
|
+
|
227
|
+
</head>
|
228
|
+
|
229
|
+
<body>
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
<form action="dataupdate.php" method="post">
|
234
|
+
|
235
|
+
<!-- $name[0] のときはdetail.php?id=1 のinputタグに入れたい-->
|
236
|
+
|
237
|
+
<input type="text" name="name" value="<?php echo $name[0]; ?>">
|
238
|
+
|
239
|
+
<!-- $email[0] のときはdetail.php?id=1 のinputタグに入れたい-->
|
240
|
+
|
241
|
+
<input type="text" name="email" value="<?php echo $email[0]; ?>">
|
242
|
+
|
243
|
+
<input type="submit" value="更新する">
|
244
|
+
|
245
|
+
</form>
|
246
|
+
|
247
|
+
</body>
|
248
|
+
|
249
|
+
</html>
|
250
|
+
|
235
251
|
```
|
236
252
|
|
237
253
|
|