0
首先,我包括分頁調用Ajax中的功能
include("pagination.php");
define("PAGINATION_LIMIT_PER_PAGE",8);
//get current page number from url, and calculation
if(isset($_GET['page'])) $page=$_GET['page'];
//default page number is 1 and start from item 1
else $page=1;
//initialize pagination variable
$start = ($page-1) * PAGINATION_LIMIT_PER_PAGE;
$stmt = $conn->query('SELECT * FROM auction_items');
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$total = count($rows);
之後,我選擇的項目存入變量
$querySel = "SELECT * FROM auction_items WHERE Item_Title LIKE :title AND Item_Expired >= NOW() AND Item_Status = 'available' ORDER BY Item_Expired ASC LIMIT ".$start.",".PAGINATION_LIMIT_PER_PAGE;
$galleryDetails = "";
之後,我使用JSON編碼的價值推到AJAX成功
$galleryDetails .=' '.pagination($page, $total).'';
print json_encode(['type'=>'3', 'passValue'=>$galleryDetails]);
問題:
我怎麼能通過pagination($page, $total)
變量,上面的代碼不能工作。 我該如何調用分頁功能?
$ galleryDetails。=''.pagination($ page,$ total);.'';你在這裏有一個分號。你需要刪除它。 – SergeyAn
刪除ald ...不能工作 –
你正面臨什麼錯誤? – Monty