window.location.href = '404';";
exit();
}
// Calculate the offset for SQL query
$offset = ($current_page - 1) * $products_per_page;
// Fetch total number of products matching the search query
$safe_query = mysqli_real_escape_string($conn, $search_query);
$total_products_query = "SELECT COUNT(*) as total FROM products WHERE cn_title LIKE '%$safe_query%' OR cn_short_description LIKE '%$safe_query%'";
$total_products_result = mysqli_query($conn, $total_products_query);
if (!$total_products_result) {
echo "";
exit();
}
$total_products_row = mysqli_fetch_assoc($total_products_result);
$total_products = intval($total_products_row['total']);
// Fetch the products for the current page
$products_query = "SELECT * FROM products WHERE cn_title LIKE '%$safe_query%' OR cn_short_description LIKE '%$safe_query%' ORDER BY id DESC LIMIT $offset, $products_per_page";
$products_result = mysqli_query($conn, $products_query);
if ($products_result && mysqli_num_rows($products_result) > 0) {
while ($product = mysqli_fetch_assoc($products_result)) {
?>
未找到匹配您查询的产品。";
}
?>