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)); ?>