-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_ele1.php
39 lines (31 loc) · 1023 Bytes
/
update_ele1.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
<?php
$css = $_POST["css"];
//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{
$id = $_POST['id'];
// var_dump($id);
$element = $_POST['element'];
// var_dump($css);
$stmt = $pdo->prepare('UPDATE css_t SET element= "' . $element . '" WHERE id = "' . $id . '"');
// var_dump($stmt);
$stmt->execute();
header('Location: top.php#disp');
}
}
?>