-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_ele.php
156 lines (136 loc) · 3.74 KB
/
update_ele.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
//PDOでデータベース接続
try {
$pdo = new PDO('mysql:host=localhost;dbname=desing_db;charset=utf8','root');
}catch (PDOException $e) {
exit( 'DbConnectError:' . $e->getMessage());
}
$sql = 'SELECT*FROM css_t ORDER BY date';
//MySQLで実行したいSQLセット。プリペアーステートメントで後から値は入れる
$stmt = $pdo->prepare($sql);
$flag = $stmt->execute();
if($flag==false){
$error = $stmt->errorInfo();
exit("ErrorQuery:".$error[2]);
}else{
if(empty($_POST)) {
echo "<a href='top.php'>こちらのページからどうぞ</a>";
exit();
}else{
if (!isset($_POST['id']) || !is_numeric($_POST['id']) ){
echo "IDエラー";
exit();
}else{
//プリペアドステートメント
$id = $_POST['id'];
$stmt = $pdo->prepare("SELECT element FROM css_t WHERE id = '" . $id . "'");
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.18.1/build/cssreset/cssreset-min.css">
<title>input</title>
<style>
#css_text{
width: 30vw;
height: 200px;
border: 5px solid #fff;
background:#a8e8f9a7;
overflow:auto;
padding:1%;
border-radius:10px;
}
#disp_update{
/* display:none; */
width: 30vw;
height:100vh;
}
form{
width:100vw;
display:flex;
justify-content:center;
align-items:center;
}
#e_tarea{
margin-top:2vh;
width:50vw;
height:80vh;
color:#929292;
background:#333;
border:none;
display:flex;
justify-content:center;
align-items:center;
padding:2%;
}
html,body{
width: 100%;
height: 100%;
font-family: Roboto,Arial,sans-serif;
scroll-behavior: smooth;
margin:0;
color:#929292;
display:flex;
flex-direction:column;
justify-content:center;
align-items:center;
}
input[type=submit]{
margin-top:2vh;
color:#929292;
background:none;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
transition: all 0.5s ease;
padding:1%;
border: 1px solid #fff;
}
input[type=submit]:hover{
color:#fff;
background:#80a7e2;
border: 1px solid #80a7e2;
}
#disp_update{
width: 30vw;
height:100vh;
}
form{
width:100vw;
display:flex;
justify-content:center;
align-items:center;
flex-direction:column;
}
input[type=text]{
margin-top:2vh;
width:50vw;
height:80vh;
color:#929292;
background:#333;
border:none;
padding:2%;
}
</style>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<!-- 修正 -->
<form action="update_ele1.php" method="post" style='display:flex;'>
<!-- <input type="text" name="element" value="<?php print_r($result['element']);?>" style='display:flex;'> -->
<textarea name="element" id="e_tarea" cols="30" rows="10"><?php print_r($result['element']);?></textarea>
<input type="hidden" name="id" value="<?=$id?>">
<input type="submit" value="変更する">
</form>
</body>
</html>
<?php
}
}
}
?>