query($sql_count); $row_count = $result_count->fetch_assoc(); $count = $row_count["count"]; // calculate the total page number $total_pages = ceil($count / $limit); $seller_id = $_SESSION['uid']; // search current page data $sql = "SELECT restaurant.restaurant_id, restaurant.name AS rname, cities.name AS cname, restaurant.location, restaurant.open_day, restaurant.close_day, restaurant.open_time, restaurant.close_time, restaurant.rating, restaurant_style.restaurant_style_name, restaurant.descrip, restaurant.fee, restaurant_style.restaurant_style_image AS image FROM restaurant JOIN cities ON restaurant.city_id = cities.id JOIN restaurant_style ON restaurant.restaurant_style_id = restaurant_style.restaurant_style_id WHERE restaurant.seller_id = $seller_id AND restaurant.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)); ?>