質問編集履歴

4

コード

2018/06/23 13:08

投稿

uep3vjz9wp
uep3vjz9wp

score20

test CHANGED
File without changes
test CHANGED
@@ -26,11 +26,9 @@
26
26
 
27
27
 
28
28
 
29
-   以下タグ
29
+ ```php
30
30
 
31
-
32
-
33
- ```<!DOCTYPE html>
31
+ <!DOCTYPE html>
34
32
 
35
33
  <html lang="ja">
36
34
 
@@ -112,13 +110,11 @@
112
110
 
113
111
  }
114
112
 
115
- ?>```
113
+ ?>
114
+
115
+ ```
116
116
 
117
117
 
118
-
119
-
120
-
121
-   以上、タグ
122
118
 
123
119
 
124
120
 
@@ -128,6 +124,8 @@
128
124
 
129
125
   下記のようなif文を使うのでしょうか?
130
126
 
127
+ ```php
128
+
131
129
  if ($_POST['category'] === '1') echo "いちばん";
132
130
 
133
131
  if ($_POST['category'] === '2') echo "にばん";
@@ -135,6 +133,8 @@
135
133
  if ($_POST['category'] === '3') echo "さんばん";
136
134
 
137
135
  if ($_POST['category'] === '4') echo "よんばん";
136
+
137
+ ```
138
138
 
139
139
 
140
140
 

3

コード

2018/06/23 13:08

投稿

uep3vjz9wp
uep3vjz9wp

score20

test CHANGED
File without changes
test CHANGED
@@ -116,6 +116,8 @@
116
116
 
117
117
 
118
118
 
119
+
120
+
119
121
    以上、タグ
120
122
 
121
123
 

2

コード

2018/06/23 13:06

投稿

uep3vjz9wp
uep3vjz9wp

score20

test CHANGED
File without changes
test CHANGED
@@ -30,7 +30,7 @@
30
30
 
31
31
 
32
32
 
33
- <!DOCTYPE html>
33
+ ```<!DOCTYPE html>
34
34
 
35
35
  <html lang="ja">
36
36
 
@@ -112,7 +112,7 @@
112
112
 
113
113
  }
114
114
 
115
- ?>
115
+ ?>```
116
116
 
117
117
 
118
118
 

1

より詳しく記入しました。

2018/06/23 13:06

投稿

uep3vjz9wp
uep3vjz9wp

score20

test CHANGED
File without changes
test CHANGED
@@ -26,6 +26,52 @@
26
26
 
27
27
 
28
28
 
29
+   以下タグ
30
+
31
+
32
+
33
+ <!DOCTYPE html>
34
+
35
+ <html lang="ja">
36
+
37
+ <head>
38
+
39
+ <meta charset="UTF-8">
40
+
41
+ <title>データ一覧</title>
42
+
43
+ </head>
44
+
45
+ <body>
46
+
47
+ <h1>2018年 データ一覧</h1>
48
+
49
+ <a href="form.html">データ新規登録</a>
50
+
51
+ <?php
52
+
53
+ require_once 'db_config.php';
54
+
55
+ try {
56
+
57
+ $dbh = new PDO('mysql:host=localhost;dbname=data_db1;charset=utf8', $user, $pass);
58
+
59
+ $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
60
+
61
+ $sql = "SELECT * FROM table_data";
62
+
63
+ $stmt = $dbh->query($sql);
64
+
65
+ $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
66
+
67
+ echo "<table>\n";
68
+
69
+ echo "<tr>\n";
70
+
71
+ echo "<th>月</th><th>日</th><th>カテゴリ</th>\n";
72
+
73
+ echo "</tr>\n";
74
+
29
75
  foreach ($result as $row) {
30
76
 
31
77
  echo "<tr>\n";
@@ -35,6 +81,42 @@
35
81
  echo "<td>" . htmlspecialchars($row['day'],ENT_QUOTES,'UTF-8') . "</td>\n";
36
82
 
37
83
  echo "<td>" . htmlspecialchars($row['category'],ENT_QUOTES,'UTF-8') . "</td>\n";
84
+
85
+
86
+
87
+ echo "<td>\n";
88
+
89
+ echo "|<a href=edit.php?id=" . htmlspecialchars($row['id'],ENT_QUOTES,'UTF-8') . ">変更</a>\n";
90
+
91
+ echo "|<a href=delete.php?id=" . htmlspecialchars($row['id'],ENT_QUOTES,'UTF-8') . ">削除</a>\n";
92
+
93
+ echo "</td>\n";
94
+
95
+
96
+
97
+
98
+
99
+ echo "</tr>\n";
100
+
101
+ }
102
+
103
+ echo "</table>\n";
104
+
105
+ $dbh = null;
106
+
107
+ } catch (PDOException $e) {
108
+
109
+ echo "エラー発生: " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8') . "<br>";
110
+
111
+ die();
112
+
113
+ }
114
+
115
+ ?>
116
+
117
+
118
+
119
+   以上、タグ
38
120
 
39
121
 
40
122