質問編集履歴
2
phpのソース全体を転記
test
CHANGED
File without changes
|
test
CHANGED
@@ -48,11 +48,69 @@
|
|
48
48
|
|
49
49
|
```ここに言語を入力
|
50
50
|
|
51
|
+
<body>
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
<?php
|
56
|
+
|
57
|
+
$dsn ='mysql:dbname=peco_table;host=localhost';
|
58
|
+
|
59
|
+
$user='root';
|
60
|
+
|
61
|
+
$password='';
|
62
|
+
|
63
|
+
$dbh=new PDO($dsn,$user,$password);
|
64
|
+
|
65
|
+
$dbh->query('SET NAMES utf8');
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
$name=$_POST['name'];
|
70
|
+
|
71
|
+
$address=$_POST['address'];
|
72
|
+
|
73
|
+
$allergy=$_POST['allergy'];
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
print 'タイトル';;
|
78
|
+
|
79
|
+
print $name;
|
80
|
+
|
81
|
+
print "詳細";
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
foreach($_POST['allergy'] as $value){
|
86
|
+
|
87
|
+
echo"{$value},";
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
51
95
|
$sql='INSERT INTO peco_an_table2(name,address,allergy)VALUES("'.$name.'","'.$address.'","'.$allergy.'")';
|
52
96
|
|
53
97
|
$stmt=$dbh->prepare($sql);
|
54
98
|
|
55
|
-
$stmt->execute();
|
99
|
+
$stmt->execute();
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
$dbh=null;
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
?>
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
</body>
|
56
114
|
|
57
115
|
```
|
58
116
|
|
1
タイトル
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
チェックボックスで複数選択した値をデータベース(MySQL)に入れるやり方を教えてください。
|
test
CHANGED
File without changes
|