-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadmin_search_page.php
More file actions
89 lines (84 loc) · 3.13 KB
/
Copy pathadmin_search_page.php
File metadata and controls
89 lines (84 loc) · 3.13 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
<?php
include 'config.php';
session_start();
$admin_id = $_SESSION['admin_id'];
if (!isset($admin_id)) {
header('location:login.php');
};
if (isset($_GET['delete'])) {
$delete_id = $_GET['delete'];
deleteBook($conn, $delete_id, $dest);
header('location:admin_search_page.php');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>страница поиска</title>
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link rel="stylesheet" href="css/admin_style.css">
<script src="js/search.js"></script>
</head>
<body>
<?php include 'admin_header.php'; ?>
<div class="heading">
<h3>страница поиска</h3>
<p><a href="admin_page.php">главная</a> / поиск </p>
</div>
<section class="search-form">
<form action="" method="post" >
<input type="text" name="search" id="dName" placeholder="начать поиск..."
class="box" style="width: 100%" >
<script>
ac.attach({
target: document.getElementById("dName"),
data: "2b-search.php"
});
</script>
<input type="submit" name="submit" value="поиск" class="btn">
</form>
</section>
<section class="books" style="padding-top: 0;">
<div class="box-container">
<?php
if (isset($_POST['submit'])) {
$search_item = $_POST['search'];
$select_books = mysqli_query($conn,
"SELECT * FROM `books` WHERE BOOK_NAME LIKE '%{$search_item}%'") or die('query failed');
if (mysqli_num_rows($select_books) > 0) {
while ($fetch_books = mysqli_fetch_assoc($select_books)) {
?>
<div class="box">
<a href="admin_detail.php?id=<?= $fetch_books['BOOK_ID'] ?>">
<img class="image"
src="uploaded_img/<?= $fetch_books['BOOK_IMG'] . '?t=' . time() ?>"
width=100%
alt=""></a>
<div class="desc">
<div class="name"><?= $fetch_books['BOOK_NAME'] ?></div>
<div class="qty">Количество: <?= $fetch_books['BOOK_AMOUNT'] ?></div>
<a href="admin_search_page.php?delete=<?= $fetch_books['BOOK_ID'] ?>"
class="delete-btn"
onclick="return confirm('Удалить эту книгу?');">Удалить</a>
</div>
</div>
<?php
}
}
else {
echo '<p class="empty">Ничего не нашлось!</p>';
}
}
else {
echo '<p class="empty">Поищите что-нибудь!</p>';
}
?>
</div>
</section>
<script src="js/admin_script.js"></script>
</body>
</html>