-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowse.php
56 lines (46 loc) · 1.04 KB
/
browse.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
<?php
session_start();
ini_set('display_errors', 0);
require_once 'includes/header.html';
include 'includes/form_limit.html';
require_once 'db/Pagination.php';
include_once 'includes/category_filter.html';
global $total_pages;
global $pageno;
$filter = $_SESSION['filter_category']??null;
$c = new Pagination;
$sqlCount = "
SELECT COUNT(*) as count FROM ads
";
$sql = "
SELECT * FROM ads
";
$where = " ";
if (isset($_POST['filter_category_button']) || $filter)
{
$category = $_POST['filter_category']??$filter;
$_SESSION['filter_category'] = $category;
if ($category !== "All")
{
$where .= " WHERE category LIKE '" . $category . "'";
}
}
$sqlCount .= $where;
$sql .= $where;
$c->setDefaults();
$c->countAds($sqlCount);
$c->PagenoOffset();
$c->SelectLimitAd($sql);
if ($total_pages > 1)
{
echo "</br><div class='pages d-inline p-2'>Pages:";
for ($pageno = 1;$pageno <= $total_pages;$pageno++)
{
?>
<a href="marketplace/browse.php?pageno=<?=$pageno?>"><?=$pageno?></a>
<?php
}
}
session_destroy();
?>
</div>