質問編集履歴

1

誤字

2017/08/22 10:49

投稿

dog57
dog57

スコア131

test CHANGED
File without changes
test CHANGED
@@ -40,289 +40,475 @@
40
40
 
41
41
 
42
42
 
43
+ ###該当のソースコード
44
+
45
+ トップページ index.html
46
+
47
+ ```html
48
+
49
+ <!DOCTYPE html>
50
+
51
+ <html lang="ja">
52
+
53
+ <head>
54
+
55
+
56
+
57
+ <meta charset="UTF-8">
58
+
59
+ <title>My Web Site</title>
60
+
61
+ <link rel="stylesheet" href="style.css">
62
+
63
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js">
64
+
65
+
66
+
67
+ </script>
68
+
69
+
70
+
71
+ </head>
72
+
73
+ <body>
74
+
75
+
76
+
77
+
78
+
79
+ <header>
80
+
81
+
82
+
83
+ <div class="header-left">
84
+
85
+ <img class="logo" src="https://www.fastpic.jp/images.php?file=3519571152.jpg" alt="ロゴ画像">
86
+
87
+ </div>
88
+
89
+
90
+
91
+ <div class="header-right">
92
+
93
+ <a href="http://onepiece-naruto.com/blog-category-12.html" class="login" target="_blank"><p class="login1">ログイン</p></a>
94
+
95
+ </div>
96
+
97
+
98
+
99
+
100
+
101
+ </header>
102
+
103
+
104
+
105
+
106
+
107
+ <div class="main">
108
+
109
+
110
+
111
+ <h1>行ってみたい<span>国</span>一覧</h1>
112
+
113
+ <form class="research" action="search.php" method="post">
114
+
115
+ <input class="research" size="40" type="text" name="nation" value="入力してください">
116
+
117
+ <input class="research" type="submit" name="research" value="検索"><br>
118
+
119
+ <a href="index2.html"><input class="research" type="button" name="btn" value="新規登録"></a>
120
+
121
+ </form>
122
+
123
+
124
+
125
+
126
+
127
+ </div>
128
+
129
+
130
+
131
+
132
+
133
+ <div class="wrapper">
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+ <table border="1">
142
+
143
+
144
+
145
+ <tr>
146
+
147
+ <th class="head">順位</th>
148
+
149
+ <th class="head">国名</th>
150
+
151
+ <th class="head">食べたい食べ物</th>
152
+
153
+ <th class="head">理由</th>
154
+
155
+ <th class="head"></th>
156
+
157
+ </tr>
158
+
159
+
160
+
161
+
162
+
163
+ <tr>
164
+
165
+ <td>1位</td>
166
+
167
+ <td>スペイン</td>
168
+
169
+ <td>パエリア</td>
170
+
171
+ <td>サッカーを見たいから</td>
172
+
173
+ <td><a href="update1.php">編集</a> <a href="#">削除</a></td>
174
+
175
+ </tr>
176
+
177
+
178
+
179
+ <tr>
180
+
181
+ <td>2位</td>
182
+
183
+ <td>アメリカ</td>
184
+
185
+ <td>グリルロブスター</td>
186
+
187
+ <td>ダンスの文化を知りたいから</td>
188
+
189
+ <td><a href="update1.php">編集</a> <a href="#">削除</a></td>
190
+
191
+ </tr>
192
+
193
+
194
+
195
+ <tr>
196
+
197
+ <td>3位</td>
198
+
199
+ <td>インド</td>
200
+
201
+ <td>カレーライス</td>
202
+
203
+ <td>発展途上の国を間近で見てみたいから</td>
204
+
205
+ <td><a href="update1.php">編集</a> <a href="#">削除</a></td>
206
+
207
+ </tr>
208
+
209
+
210
+
211
+ <tr>
212
+
213
+ <td>4位</td>
214
+
215
+ <td>タイ</td>
216
+
217
+ <td>ガパオ</td>
218
+
219
+ <td>バンコクの発展具合を見てみたいから</td>
220
+
221
+ <td><a href="update1.php">編集</a> <a href="#">削除</a></td>
222
+
223
+ </tr>
224
+
225
+
226
+
227
+ <tr>
228
+
229
+ <td>5位</td>
230
+
231
+ <td>フィリピン</td>
232
+
233
+ <td>アドボ </td>
234
+
235
+ <td>友達が楽しそうに働いているから</td>
236
+
237
+ <td><a href="update1.php">編集</a> <a href="#">削除</a></td>
238
+
239
+ </tr>
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+ </table>
248
+
249
+
250
+
251
+ </div>
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+ <footer>
266
+
267
+
268
+
269
+
270
+
271
+ <div class="footer-left">
272
+
273
+ <img src="https://www.fastpic.jp/images.php?file=3519571152.jpg" alt="ロゴ画像">
274
+
275
+ <p>&copy travel enjoy.</p>
276
+
277
+ </div>
278
+
279
+
280
+
281
+ <div class="footer-list">
282
+
283
+ <ul>
284
+
285
+ <li><a href="https://www.airbnb.jp/">利用規約</a></li>
286
+
287
+ <li><a href="https://www.uber.com/ja-JP/">プライバシー</a></li>
288
+
289
+ <li><a href="https://tabelog.com/tokyo/A1307/A130701/13191934/">アクセシビリティ</a></li>
290
+
291
+ </ul>
292
+
293
+ </div>
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+ </footer>
302
+
303
+
304
+
305
+ <script src="script.js">
306
+
307
+
308
+
309
+ </script>
310
+
311
+
312
+
313
+
314
+
315
+ </body>
316
+
317
+ </html>
318
+
319
+
320
+
43
321
  ```
44
322
 
323
+
324
+
325
+ 編集ボタンを押したページ update1.php
326
+
327
+ ```php
328
+
329
+ <?php
330
+
331
+
332
+
333
+ header("Content-type: text/html; charset=utf-8");
334
+
335
+
336
+
45
- エラー分は出ていないですが、おそらくupdate.phpのHTMLの中のforeach
337
+ require_once("index_db.php");
338
+
339
+
340
+
341
+
342
+
343
+ $sql = "SELECT id, rank, nation, food, reason FROM country";
344
+
345
+ $statement = $pdo->query($sql);
346
+
347
+
348
+
349
+ // 結果の取得
350
+
351
+ $country = array();
352
+
353
+ foreach ($statement as $row) {
354
+
355
+ $country[] = $row;
356
+
357
+ }
358
+
359
+ var_dump($country);
360
+
361
+
362
+
363
+ // データベース切断
364
+
365
+ $pdo = null;
366
+
367
+
368
+
369
+ ?>
370
+
371
+
372
+
373
+ <!DOCTYPE html>
374
+
375
+ <html>
376
+
377
+ <head>
378
+
379
+ <title>国一覧</title>
380
+
381
+ </head>
382
+
383
+ <body>
384
+
385
+ <h1>国一覧</h1>
386
+
387
+
388
+
389
+ <table border='1'>
390
+
391
+ <tr><td>id</td><td>順位</td><td>国名</td><td>食べたい食べ物</td><td>理由</td></tr>
392
+
393
+
394
+
395
+ <?php
396
+
397
+ foreach($rows as $row){
398
+
399
+ ?>
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+ <tr>
408
+
409
+ <form action="update2.php" method="post">
410
+
411
+ <td><?=$row['id']?></td>
412
+
413
+ <td><?=htmlspecialchars($row['rank'],ENT_QUOTES,'UTF-8')?></td>
414
+
415
+ <td><?=htmlspecialchars($row['nation'],ENT_QUOTES,'UTF-8')?></td>
416
+
417
+ <td><?=htmlspecialchars($row['food'],ENT_QUOTES,'UTF-8')?></td>
418
+
419
+ <td><?=htmlspecialchars($row['reason'],ENT_QUOTES,'UTF-8')?></td>
420
+
421
+ <input type="submit" value="変更する">
422
+
423
+ </form>
424
+
425
+ </tr>
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+ <?php
434
+
435
+ }
436
+
437
+ ?>
438
+
439
+
440
+
441
+ </table>
442
+
443
+
444
+
445
+ </body>
446
+
447
+ </html>
448
+
449
+
46
450
 
47
451
  ```
48
452
 
49
453
 
50
454
 
51
- ###該当のソースコード
52
-
53
- トップページ index.html
54
-
55
- ```html
56
-
57
- <!DOCTYPE html>
58
-
59
- <html lang="ja">
60
-
61
- <head>
62
-
63
-
64
-
65
- <meta charset="UTF-8">
66
-
67
- <title>My Web Site</title>
68
-
69
- <link rel="stylesheet" href="style.css">
70
-
71
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js">
72
-
73
-
74
-
75
- </script>
76
-
77
-
78
-
79
- </head>
80
-
81
- <body>
82
-
83
-
84
-
85
-
86
-
87
- <header>
88
-
89
-
90
-
91
- <div class="header-left">
92
-
93
- <img class="logo" src="https://www.fastpic.jp/images.php?file=3519571152.jpg" alt="ロゴ画像">
94
-
95
- </div>
96
-
97
-
98
-
99
- <div class="header-right">
100
-
101
- <a href="http://onepiece-naruto.com/blog-category-12.html" class="login" target="_blank"><p class="login1">ログイン</p></a>
102
-
103
- </div>
104
-
105
-
106
-
107
-
108
-
109
- </header>
110
-
111
-
112
-
113
-
114
-
115
- <div class="main">
116
-
117
-
118
-
119
- <h1>行ってみたい<span>国</span>一覧</h1>
120
-
121
- <form class="research" action="search.php" method="post">
122
-
123
- <input class="research" size="40" type="text" name="nation" value="入力してください">
124
-
125
- <input class="research" type="submit" name="research" value="検索"><br>
126
-
127
- <a href="index2.html"><input class="research" type="button" name="btn" value="新規登録"></a>
128
-
129
- </form>
130
-
131
-
132
-
133
-
134
-
135
- </div>
136
-
137
-
138
-
139
-
140
-
141
- <div class="wrapper">
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
- <table border="1">
150
-
151
-
152
-
153
- <tr>
154
-
155
- <th class="head">順位</th>
156
-
157
- <th class="head">国名</th>
158
-
159
- <th class="head">食べたい食べ物</th>
160
-
161
- <th class="head">理由</th>
162
-
163
- <th class="head"></th>
164
-
165
- </tr>
166
-
167
-
168
-
169
-
170
-
171
- <tr>
172
-
173
- <td>1位</td>
174
-
175
- <td>スペイン</td>
176
-
177
- <td>パエリア</td>
178
-
179
- <td>サッカーを見たいから</td>
180
-
181
- <td><a href="update1.php">編集</a> <a href="#">削除</a></td>
182
-
183
- </tr>
184
-
185
-
186
-
187
- <tr>
188
-
189
- <td>2位</td>
190
-
191
- <td>アメリカ</td>
192
-
193
- <td>グリルロブスター</td>
194
-
195
- <td>ダンスの文化を知りたいから</td>
196
-
197
- <td><a href="update1.php">編集</a> <a href="#">削除</a></td>
198
-
199
- </tr>
200
-
201
-
202
-
203
- <tr>
204
-
205
- <td>3位</td>
206
-
207
- <td>インド</td>
208
-
209
- <td>カレーライス</td>
210
-
211
- <td>発展途上の国を間近で見てみたいから</td>
212
-
213
- <td><a href="update1.php">編集</a> <a href="#">削除</a></td>
214
-
215
- </tr>
216
-
217
-
218
-
219
- <tr>
220
-
221
- <td>4位</td>
222
-
223
- <td>タイ</td>
224
-
225
- <td>ガパオ</td>
226
-
227
- <td>バンコクの発展具合を見てみたいから</td>
228
-
229
- <td><a href="update1.php">編集</a> <a href="#">削除</a></td>
230
-
231
- </tr>
232
-
233
-
234
-
235
- <tr>
236
-
237
- <td>5位</td>
238
-
239
- <td>フィリピン</td>
240
-
241
- <td>アドボ </td>
242
-
243
- <td>友達が楽しそうに働いているから</td>
244
-
245
- <td><a href="update1.php">編集</a> <a href="#">削除</a></td>
246
-
247
- </tr>
248
-
249
-
250
-
251
-
252
-
253
-
254
-
255
- </table>
256
-
257
-
258
-
259
- </div>
260
-
261
-
262
-
263
-
264
-
265
-
266
-
267
-
268
-
269
-
270
-
271
-
272
-
273
- <footer>
274
-
275
-
276
-
277
-
278
-
279
- <div class="footer-left">
280
-
281
- <img src="https://www.fastpic.jp/images.php?file=3519571152.jpg" alt="ロゴ画像">
282
-
283
- <p>&copy travel enjoy.</p>
284
-
285
- </div>
286
-
287
-
288
-
289
- <div class="footer-list">
290
-
291
- <ul>
292
-
293
- <li><a href="https://www.airbnb.jp/">利用規約</a></li>
294
-
295
- <li><a href="https://www.uber.com/ja-JP/">プライバシー</a></li>
296
-
297
- <li><a href="https://tabelog.com/tokyo/A1307/A130701/13191934/">アクセシビリティ</a></li>
298
-
299
- </ul>
300
-
301
- </div>
302
-
303
-
304
-
305
-
306
-
307
-
308
-
309
- </footer>
310
-
311
-
312
-
313
- <script src="script.js">
314
-
315
-
316
-
317
- </script>
318
-
319
-
320
-
321
-
322
-
323
- </body>
324
-
325
- </html>
455
+ タベーに繋げるための専用のsql文
456
+
457
+ ```php
458
+
459
+ <?php
460
+
461
+ //DBにMysql、データベース名・testを指定。
462
+
463
+ $dsn = 'mysql:dbname=uriage;host=localhost;charset=utf8';
464
+
465
+
466
+
467
+ //DBに接続するためのユーザー名・パスワードを設定
468
+
469
+ $user = 'andrew';
470
+
471
+ $password = 'andrew135';
472
+
473
+ $dbName = "uriage";
474
+
475
+
476
+
477
+ try {
478
+
479
+
480
+
481
+
482
+
483
+
484
+
485
+ //データーベースに接続
486
+
487
+ $pdo = new PDO($dsn, $user, $password);
488
+
489
+
490
+
491
+ //ここに処理を記載
492
+
493
+
494
+
495
+
496
+
497
+
498
+
499
+ }
500
+
501
+ //エラー内容表示
502
+
503
+ catch (Exception $e) {
504
+
505
+ print "エラー!: " . $e->getMessage() . "<br/>";
506
+
507
+ die();
508
+
509
+ }
510
+
511
+ ?>
326
512
 
327
513
 
328
514
 
@@ -330,200 +516,6 @@
330
516
 
331
517
 
332
518
 
333
- 編集ボタンを押したページ update1.php
334
-
335
- ```php
336
-
337
- <?php
338
-
339
-
340
-
341
- header("Content-type: text/html; charset=utf-8");
342
-
343
-
344
-
345
- require_once("index_db.php");
346
-
347
-
348
-
349
-
350
-
351
- $sql = "SELECT id, rank, nation, food, reason FROM country";
352
-
353
- $statement = $pdo->query($sql);
354
-
355
-
356
-
357
- // 結果の取得
358
-
359
- $country = array();
360
-
361
- foreach ($statement as $row) {
362
-
363
- $country[] = $row;
364
-
365
- }
366
-
367
- var_dump($country);
368
-
369
-
370
-
371
- // データベース切断
372
-
373
- $pdo = null;
374
-
375
-
376
-
377
- ?>
378
-
379
-
380
-
381
- <!DOCTYPE html>
382
-
383
- <html>
384
-
385
- <head>
386
-
387
- <title>国一覧</title>
388
-
389
- </head>
390
-
391
- <body>
392
-
393
- <h1>国一覧</h1>
394
-
395
-
396
-
397
- <table border='1'>
398
-
399
- <tr><td>id</td><td>順位</td><td>国名</td><td>食べたい食べ物</td><td>理由</td></tr>
400
-
401
-
402
-
403
- <?php
404
-
405
- foreach($rows as $row){
406
-
407
- ?>
408
-
409
-
410
-
411
-
412
-
413
-
414
-
415
- <tr>
416
-
417
- <form action="update2.php" method="post">
418
-
419
- <td><?=$row['id']?></td>
420
-
421
- <td><?=htmlspecialchars($row['rank'],ENT_QUOTES,'UTF-8')?></td>
422
-
423
- <td><?=htmlspecialchars($row['nation'],ENT_QUOTES,'UTF-8')?></td>
424
-
425
- <td><?=htmlspecialchars($row['food'],ENT_QUOTES,'UTF-8')?></td>
426
-
427
- <td><?=htmlspecialchars($row['reason'],ENT_QUOTES,'UTF-8')?></td>
428
-
429
- <input type="submit" value="変更する">
430
-
431
- </form>
432
-
433
- </tr>
434
-
435
-
436
-
437
-
438
-
439
-
440
-
441
- <?php
442
-
443
- }
444
-
445
- ?>
446
-
447
-
448
-
449
- </table>
450
-
451
-
452
-
453
- </body>
454
-
455
- </html>
456
-
457
-
458
-
459
- ```
460
-
461
-
462
-
463
- データベースに繋げるための専用のsql文
464
-
465
- ```php
466
-
467
- <?php
468
-
469
- //DBにMysql、データベース名・testを指定。
470
-
471
- $dsn = 'mysql:dbname=uriage;host=localhost;charset=utf8';
472
-
473
-
474
-
475
- //DBに接続するためのユーザー名・パスワードを設定
476
-
477
- $user = 'andrew';
478
-
479
- $password = 'andrew135';
480
-
481
- $dbName = "uriage";
482
-
483
-
484
-
485
- try {
486
-
487
-
488
-
489
-
490
-
491
-
492
-
493
- //データーベースに接続
494
-
495
- $pdo = new PDO($dsn, $user, $password);
496
-
497
-
498
-
499
- //ここに処理を記載
500
-
501
-
502
-
503
-
504
-
505
-
506
-
507
- }
508
-
509
- //エラー内容表示
510
-
511
- catch (Exception $e) {
512
-
513
- print "エラー!: " . $e->getMessage() . "<br/>";
514
-
515
- die();
516
-
517
- }
518
-
519
- ?>
520
-
521
-
522
-
523
- ```
524
-
525
-
526
-
527
519
 
528
520
 
529
521