52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
session_start();
|
|
if (!isset($_SESSION['usertype']) || $_SESSION['usertype'] !== "seller") {
|
|
header('Location: ../../index.php');
|
|
exit();
|
|
}
|
|
include "../ConnectDB.php";
|
|
$q = $_REQUEST["q"];
|
|
$page = isset($_REQUEST["page"]) ? $_REQUEST["page"] : 1;
|
|
$limit = 3;
|
|
$offset = ($page - 1) * $limit;
|
|
|
|
|
|
$result_count = $conn->query("SELECT COUNT(*) AS count FROM hotel WHERE name LIKE '%$q%'");
|
|
$row_count = $result_count->fetch_assoc();
|
|
$count = $row_count["count"];
|
|
|
|
|
|
$total_pages = ceil($count / $limit);
|
|
|
|
|
|
$seller_id = $_SESSION['uid'];
|
|
|
|
$sql = "SELECT
|
|
hotel.hotel_id,
|
|
hotel.name AS hname,
|
|
cities.name AS cname,
|
|
hotel_type.hotel_type_name,
|
|
hotel.rating,
|
|
hotel_type.hotel_type_image AS image
|
|
FROM
|
|
hotel
|
|
JOIN
|
|
cities ON hotel.city_id = cities.id
|
|
JOIN
|
|
hotel_type ON hotel.hotel_type_id = hotel_type.hotel_type_id
|
|
WHERE hotel.seller_id = $seller_id AND hotel.name LIKE '%" . $q . "%'
|
|
";
|
|
$result = $conn->query($sql);
|
|
$data = array();
|
|
if ($result->num_rows > 0) {
|
|
while($row = $result->fetch_assoc()) {
|
|
$row["image"] = base64_encode($row["image"]);
|
|
$data[] = $row;
|
|
}
|
|
} else {
|
|
$data[] = "No result";
|
|
}
|
|
|
|
echo json_encode(array("data" => $data, "total_pages" => $total_pages));
|
|
?>
|