2013-06-06 84 views
0

我有這個問題與分頁。問題與分頁在php

我有這個PHP代碼在這裏:

$page = $_POST['page']; 
$cur_page = $page; 
$page -= 1; 
$per_page = 15; 
$previous_btn = true; 
$next_btn = true; 
$first_btn = true; 
$last_btn = true; 
$start = $page * $per_page; 

我有這個疑問在這裏:

$query_pag_data = 'SELECT 
    matching.date, 
    matching.points, 
    matching.time, 
    matching.location, 
    matching.epos_id, 
    rbpos_epos.epos_id, 
    rbpos_epos.location 
FROM 
    matching 
LEFT JOIN 
    rbpos_epos ON matching.epos_id = rbpos_epos.epos_id 
WHERE 
    matching.user_id = ".$id_user." LIMIT $start, $per_page'; 

我得到$start變量是不確定的。我想它與查詢有關,因爲如果我把另一個查詢變得更簡單,它就可以工作。
請幫助我。

謝謝。

回答

0

在查詢中使用雙引號,因爲$start$per_page都是字符串變量不

$query_pag_data = "SELECT 
matching.date, 
matching.points, 
matching.time, 
matching.location, 
matching.epos_id, 
rbpos_epos.epos_id, 
rbpos_epos.location 
FROM 
matching 
LEFT JOIN 
rbpos_epos ON matching.epos_id = rbpos_epos.epos_id 
WHERE 
matching.user_id = $id_user LIMIT $start, $per_page"; 
+0

完美完美:) –