2011-02-11 39 views
1

錯誤的所有日期的項目上顯示從DATEBASE所有日期的項目:錯誤展出從DATEBASE

上DATEBASE:

Title1 
Title2 
Title3 

PHP代碼:

$postdb = mysql_query("SELECT * FROM wtable"); 
$post = mysql_fetch_assoc($postdb); 

while ($poste = @mysql_fetch_array($postdb)) 
    { 
    echo $poste['posttitle']; 
    echo "<br />"; 
    } 

輸出:

Title2 
Title3 
+1

評論此行`// $ =後mysql_fetch_assoc($ postdb);` 因爲你已經取出的第一排,但沒有迴應 – 2011-02-11 12:28:03

回答

3
$post = mysql_fetch_assoc($postdb); 

返回第一個結果,然後向前移動遊標。

註釋掉此行並重試。

例子:

$postdb = mysql_query("SELECT * FROM wtable"); 
//$post = mysql_fetch_assoc($postdb); <-- comment out this line 

while ($poste = mysql_fetch_array($postdb)) { // <-- don't use @ here, we want to know if something went wrong! 
    echo $poste['posttitle']; 
    echo "<br />"; 
}