-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.html
More file actions
48 lines (41 loc) · 1.77 KB
/
Copy pathview.html
File metadata and controls
48 lines (41 loc) · 1.77 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
<!DOCTYPE html>
<html>
<head>
<title>Book Details</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" />
</head>
<body class="container mt-4">
<h2>Book Details</h2>
<table class="table table-bordered">
<tbody>
<tr><th>id:</th><td id="bookId"></td></tr>
<tr><th>book title:</th><td id="bookTitle"></td></tr>
<tr><th>author name:</th><td id="authorName"></td></tr>
<tr>
<th>Book Cover:</th>
<td><img id="bookCoverImg" src="" alt="Book Cover" style="max-width: 150px; max-height: 200px;" /></td>
</tr>
<tr><th>genre:</th><td id="genre"></td></tr>
<tr><th>publication year:</th><td id="publicationYear"></td></tr>
<tr><th>quantity:</th><td id="quantity"></td></tr>
</tbody>
</table>
<a href="index.html" class="btn btn-secondary">Back</a>
<script>
const urlParams = new URLSearchParams(window.location.search);
const id = urlParams.get('id');
fetch(`http://localhost:8000/library_project/books.php?id=${id}`)
.then(res => res.json())
.then(data => {
document.getElementById('bookId').textContent = data.id;
document.getElementById('bookTitle').textContent = data.book_title;
document.getElementById('authorName').textContent = data.author_name;
document.getElementById('genre').textContent = data.genre;
document.getElementById('publicationYear').textContent = data.publication_year;
document.getElementById('quantity').textContent = data.quantity;
// 显示封面图片,调用 image.php
document.getElementById('bookCoverImg').src = `http://localhost:8000/library_project/image.php?id=${id}`;
});
</script>
</body>
</html>