Файл: page/shop/search.php
Строк: 43
<?php
$title = 'Поиск по магазину';
require_once($_SERVER["DOCUMENT_ROOT"]."/inc/head.php");
if ($sys['modules']['shop'] == 1) {
echo '<div class="title">Поиск по магазину</div>
<div class="menu">
<form action="" method="GET">
<input type="text" name="search" value="'.$search.'">
<input type="submit" value="Поиск">
</form></div>';
if ($search) {
$keywords = preg_replace("/[s,]+/", "|", $search);
$stmt_num = $connect->prepare("select count(*) from `shop` where `status` = '1' and `name` rlike :keywords or `text` rlike :keywords or `tags` rlike :keywords");
$stmt_num->bindValue(':keywords', $keywords);
$stmt_num->execute();
$count_res = $stmt_num->fetchColumn();
if ($count_res == 0) {
echo '<div class="menu">Ничего не найдено!</div>';
} else {
echo '<div class="menu">Найдено по запросу: '.$count_res.'</div>';
$page = new Pagination($count_res, 10);
$page->setLink('?search=' . $search . '&');
$data = $connect->prepare("select * from `shop` where `status` = '1' and (`name` rlike :keywords or `text` rlike :keywords or `tags` rlike :keywords) order by `id` desc limit :start, 10");
$data->bindValue(':keywords', $keywords);
$data->bindValue(':start', $page->start, PDO::PARAM_INT);
$data->execute();
$sql = $data->fetchAll();
foreach ($sql as $row) {
echo linkShop($row);
}
$page->navigation();
}
}
echo '<div class="forlink"><a href="/shop" class="links"><img src="/img/shop.png" alt="">Магазин скриптов</a></div>';
} else {
header('Location: /');
}
require($_SERVER["DOCUMENT_ROOT"]."/inc/foot.php");
?>