-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
54 lines (41 loc) · 941 Bytes
/
search.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
<?php
ini_set('display_errors', 0);
include_once 'includes/header.html';
require_once 'db/SelectAd.php';
require_once 'db/Pagination.php';
$search = $_POST['search'];
if (isset($_POST['search_button']))
{
if (!empty($search))
{
$search = str_replace(' ', '%', $search);
}
else
{
header('Location:browse.php');
}
}
global $total_pages;
global $pageno;
$c = new Pagination;
$c->setDefaults();
$c->countAds("
SELECT COUNT(*) as count FROM ads WHERE title LIKE '%{$search}%' OR content LIKE '%{$search}%';
");
$c->PagenoOffset();
$c->SelectLimitAd("
SELECT * FROM ads WHERE title LIKE '%{$search}%' OR content LIKE '%{$search}%';
");
if ($total_pages > 1)
{
echo "</br><div class='pages d-inline p-2'>Pages:";
for ($pageno = 1;$pageno <= $total_pages;$pageno++)
{
?>
<a href="marketplace/search.php?pageno=<?=$pageno?>"><?=$pageno?></a>
<?php
}
}
session_destroy();
?>
</div>