-
Notifications
You must be signed in to change notification settings - Fork 0
/
showItems.php
93 lines (80 loc) · 4.48 KB
/
showItems.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
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
<?php
$counter = 0;
// COUNTING THE ITEMS.
while($row = $result->fetch_assoc()){
if(empty($category) && empty($location) && empty($searched))
$counter++;
elseif(empty($location) && !empty($category) && empty($searched) && strpos(strtolower($row["ItemName"]), strtolower($category)) !== false)
$counter++;
elseif(empty($category) && !empty($location) && empty($searched) && strpos(strtolower($row["Location"]), strtolower($location)) !== false )
$counter++;
elseif(!empty($category) && !empty($location) && empty($searched) && strpos(strtolower($row["Location"]), strtolower($location)) !== false && strpos(strtolower($row["ItemName"]), strtolower($category)) !== false)
$counter++;
elseif(empty($category) && empty($location) && !empty($searched) && strpos(strtolower($row["Descript"]), strtolower($searched)) !== false)
$counter++;
elseif(!empty($category) && empty($location) && !empty($searched) && strpos(strtolower($row["Descript"]), strtolower($searched)) !== false && strpos(strtolower($row["ItemName"]), strtolower($category)) !== false)
$counter++;
elseif(empty($category) && !empty($location) && !empty($searched) && strpos(strtolower($row["Descript"]), strtolower($searched)) !== false && strpos(strtolower($row["Location"]), strtolower($location)) !== false)
$counter++;
elseif(!empty($category) && !empty($location) && !empty($searched) && strpos(strtolower($row["Descript"]), strtolower($searched)) !== false && strpos(strtolower($row["Location"]), strtolower($location)) !== false && strpos(strtolower($row["ItemName"]), strtolower($category)) !== false)
$counter++;
}
if($totalItems != $counter){
$totalItems = $counter;
$totalPages = ceil($totalItems / $itemsPerPage);
}
$startItemIndex = ($currentPage-1) * ($itemsPerPage);
$counter = 0;
$index = -$startItemIndex;
$endItemIndex = $currentPage * $itemsPerPage;
$sql1 = "SELECT * FROM Items ORDER BY ID DESC";
$result1 = $conn->query($sql1);
// SHOWING THE ITEMS.
while($row = $result1->fetch_assoc()){
if($counter < $totalItems && $counter < $itemsPerPage && $index >= 0)
{
if(empty($category) && empty($location) && empty($searched))
{
include 'item.php';
$counter++;
$indexCounterState = 0;
}
elseif(empty($location) && !empty($category) && empty($searched) && strpos(strtolower($row["ItemName"]), strtolower($category)) !== false){
include 'item.php';
$counter++;
$indexCounterState = 1;
}
elseif(empty($category) && !empty($location) && empty($searched) && strpos(strtolower($row["Location"]), strtolower($location)) !== false ){
include 'item.php';
$counter++;
$indexCounterState = 1;
}
elseif(!empty($category) && !empty($location) && empty($searched) && strpos(strtolower($row["Location"]), strtolower($location)) !== false && strpos(strtolower($row["ItemName"]), strtolower($category)) !== false){
include 'item.php';
$counter++;
$indexCounterState = 1;
}
elseif(empty($category) && empty($location) && !empty($searched) && strpos(strtolower($row["Descript"]), strtolower($searched)) !== false){
include 'item.php';
$counter++;
$indexCounterState = 1;
}
elseif(!empty($category) && empty($location) && !empty($searched) && strpos(strtolower($row["Descript"]), strtolower($searched)) !== false && strpos(strtolower($row["ItemName"]), strtolower($category)) !== false){
include 'item.php';
$counter++;
$indexCounterState = 1;
}
elseif(empty($category) && !empty($location) && !empty($searched) && strpos(strtolower($row["Descript"]), strtolower($searched)) !== false && strpos(strtolower($row["Location"]), strtolower($location)) !== false){
include 'item.php';
$counter++;
$indexCounterState = 1;
}
elseif(!empty($category) && !empty($location) && !empty($searched) && strpos(strtolower($row["Descript"]), strtolower($searched)) !== false && strpos(strtolower($row["Location"]), strtolower($location)) !== false && strpos(strtolower($row["ItemName"]), strtolower($category)) !== false){
include 'item.php';
$counter++;
$indexCounterState = 1;
}
}
$index++;
}
?>