回答編集履歴

1

内容追記

2018/04/26 07:45

投稿

stampdoor
stampdoor

スコア483

test CHANGED
@@ -15,8 +15,6 @@
15
15
  $stmt = $dbh->query("SELECT id, code, prod_name, mount, category, end_date from hozon");
16
16
 
17
17
  echo "<form name='show' method='post' action='index.php'>";//formは外側に
18
-
19
- echo "<table>";//tableをforeachの外に出す
20
18
 
21
19
  echo "<tbody>";//tbodyもforeachの外に出す
22
20
 
@@ -46,8 +44,6 @@
46
44
 
47
45
  echo "</tbody>";//tbodyもforeachの外に出す
48
46
 
49
- echo "</table>";//tableが閉じていないので閉じる foreachの外に出す
50
-
51
47
  echo "</form>";//formは外側に
52
48
 
53
49
 
@@ -55,3 +51,45 @@
55
51
  }
56
52
 
57
53
  ```
54
+
55
+
56
+
57
+ ### 追記
58
+
59
+ よく見たらtableの書き方も不思議なので修正が必要ですね。
60
+
61
+ thead内でループさせるのではなく、theadの後にして、
62
+
63
+ ループはtableを出力せずにtbodyの中身だけで良いでしょう。
64
+
65
+
66
+
67
+ ```html
68
+
69
+ <table>
70
+
71
+ <thead>
72
+
73
+ <tr>
74
+
75
+ <th>商品コード</th>
76
+
77
+ <th>商品名</th>
78
+
79
+ <th>数量</th>
80
+
81
+ <th>種目</th>
82
+
83
+ <th>賞味期限</th>
84
+
85
+ <th>ボタン</th>
86
+
87
+ </tr>
88
+
89
+ </thead>
90
+
91
+ <?php showSQL() ?>
92
+
93
+ </table>
94
+
95
+ ```