-
Notifications
You must be signed in to change notification settings - Fork 11
/
cat-items.php
108 lines (78 loc) · 3.22 KB
/
cat-items.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
session_start();
if (isset($_GET['name'])) {
$_SESSION['cat'] = $_GET['name'];
} else {
$categoryName = $_SESSION['cat'];
}
$categoryName = $_SESSION['cat'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= htmlentities($categoryName) ?></title>
<!--font awsome-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" />
<link rel="stylesheet" href="./styles/home_style.css">
<link rel="stylesheet" href="./styles/footer.css">
<link rel="stylesheet" href="./styles/navbar.css" />
<link rel="stylesheet" href="./styles/cat-items.css" />
<link rel="icon" type="image/ico" href="./Image/logo1.ico">
<?php require_once "head.php" ?>
</head>
<body>
<?php require_once "nav.php" ?>
<?php
require_once("./home/homeDb.php");
require_once("./home/item-component.php");
$my=array("a"=>"red","b"=>"green","c"=>"blue");
echo array_search("red",$my);
?>
<div class="container">
<div class="row text-center py-5">
<?php
$results_per_page = 8;
$sql = "SELECT * FROM productb where FIND_IN_SET('$categoryName',product_category)";
$results = mysqli_query($con, $sql);
$number_of_result = mysqli_num_rows($results);
$number_of_page = ceil($number_of_result / $results_per_page);
if (!isset($_GET['page'])) {
$page = 1;
} else {
$page = $_GET['page'];
}
$page_first_result = ($page - 1) * $results_per_page;
$query = "SELECT *FROM productb where FIND_IN_SET('$categoryName',product_category) LIMIT " . $page_first_result . ',' . $results_per_page;
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
component($row['product_name'], $row['product_price'], $row['second_price'], $row['product_image'], $row['id']);
}
}
?>
</div>
<div class="row justify-content-center">
<?php
if ($number_of_page > 1) {
for ($page = 1; $page <= $number_of_page; ++$page) {
echo ('<a href = "cat-items.php?page=' . $page . '"><button class="btn btn-outline-info my-3" id="pages">
' . $page . '</button> </a>');
}
}
function countAll($table){
$dbh = dbConnect();
$sql = "select * from `$table`";
$stmt = $dbh->prepare($sql);
$stmt->execute();
return $stmt->rowCount();
}
?>
</div>
</div>
<?php require_once "script.php" ?>
<?php require_once "delete_process.php" ?>
<?php require_once "footer.php" ?>
</body>
</html>