-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbook_search.php
More file actions
44 lines (32 loc) · 1.17 KB
/
book_search.php
File metadata and controls
44 lines (32 loc) · 1.17 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
<?php
/**
* Created by PhpStorm.
* User: Hoc_Anms
* Date: 8/22/2018
* Time: 10:35 AM
*/
// if submit form ->action
if (isset($_GET['search']))
{
// addslashes fix sql injection
$search = addslashes($_GET['search']);
// if $search empty create notification.
if (empty($search)) {
}
else {
// use statement "like" in sql and use % of php to search data exactly.
// Connect DB
$conn = mysqli_connect("localhost", "root", "", "myDB");
mysqli_set_charset($conn, "utf8");
// do query to DB
$querys = mysqli_query($conn, "SELECT tb_book.b_id,tb_book.b_name,tb_book.b_author,tb_book.b_date,tb_style.s_style FROM tb_book
INNER JOIN tb_style ON tb_book.b_style=tb_style.s_id
WHERE
b_id LIKE '%$search%'
OR b_name LIKE '%$search%'
OR b_author LIKE '%$search%'
OR s_style LIKE '%$search%'
");
}
}
?>