-
Notifications
You must be signed in to change notification settings - Fork 0
/
setSqlQuery.php
37 lines (30 loc) · 894 Bytes
/
setSqlQuery.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
<?php
include_once 'includes/db_connect.php';
// Check connection
if ($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
$All = "List All";
$readFalse = "Unread";
$readTrue = "Read";
$givenTrue = "Lend";
$false = "No";
$true = "Yes";
if(isset($_POST['filterBtn'])){
$book = $_POST['selection'];
if($book == $All){
$sql = "SELECT * FROM $table_name ORDER BY $author";
}
elseif($book == $readFalse){
$sql = "SELECT * FROM $table_name WHERE $read='$false' ORDER BY $author";
}
elseif($book == $readTrue){
$sql = "SELECT * FROM $table_name WHERE $read='$true' ORDER BY $author";
}
elseif($book == $givenTrue){
$sql = "SELECT * FROM $table_name WHERE $lend='$true' ORDER BY $author";
}
else {
$sql = "SELECT * FROM $table_name WHERE $language='$book' or $category='$book' ORDER BY $author";
}
}