-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateData.php
More file actions
122 lines (101 loc) · 4.24 KB
/
Copy pathupdateData.php
File metadata and controls
122 lines (101 loc) · 4.24 KB
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
<?php
//連接php與sql
//$conn = mysqli_connect("localhost","administrator","123456","bookcase");
require 'connect.php';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>修改書籍</title>
<style>
.bookname-group, .isbn-group,.comment-group ,.category-group{
margin-bottom: 20px; /* 調整這裡的數值來改變元素之間的間距 */
}
.form-check-label {
font-size: 20px;
}
.form-check-inline {
display: inline-block;
margin-left: 5px; /* 可選:設置選項之間的間距 */
}
</style>
</head>
<body>
<?php
// 獲取 POST 傳遞的書本 ID
$bookId = $_POST['bookId'];
// 查詢該書的資料
$sql = "SELECT 書名, ISBN, 介紹, 類型 FROM books WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $bookId);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$bookName = $row['書名'];
$isbn = $row['ISBN'];
$introduction = $row['介紹'];
$category = $row['類型'];
} else {
echo "找不到該書籍";
exit();
}
$stmt->close();
$conn->close();
?>
<center>
<h1><b>修改書籍</b><h1>
<form action="updateDataExtra.php" method="post">
<input type='hidden' name='bookId' value=" <?php echo $bookId; ?>">
<div class="bookname-group">
<label>書名:</label>
<input type="text" class="form-control " id="bookName" name="bookName"
value="<?php echo $bookName; ?>" required>
</div>
<div class="isbn-group">
<label>ISBN:</label>
<input type="text" class="form-control" id="ISBN" name="ISBN" value="<?php echo $isbn; ?>" required>
</div>
<div class="comment-group">
<label>介紹:</label>
<textarea class="form-control" id="introduction" name="introduction" rows="1" value="<?php echo $introduction; ?>"></textarea>
</div>
<!--類型-->
<div class="category-group">
<label>類型:</label>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="option藝術" value="藝術">
<label class="form-check-label " for="inlineRadio1">藝術</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="option人文地史" value="人文地史">
<label class="form-check-label" for="option人文地史">人文地史</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="option哲學" value="哲學">
<label class="form-check-label" for="option哲學">哲學</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="option語言文學" value="語言文學">
<label class="form-check-label" for="option語言文學">語言文學</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="option其他" value="其他">
<label class="form-check-label" for="option其他">其他</label>
</div>
</div>
<!--按鈕-->
<div class="text-center mt-8">
<button type="submit" class="btn btn-primary" target="_blank" text-#7d6f6fe8>
修改
</button>
<button type="submit" class="btn btn-primary" target="_blank" text-#7d6f6fe8>
<a href="http://localhost/bookcase/bookMainCode.php">返回</a>
</button>
</div>
</form>
</center>
</body>
</html>