0
我一直試圖在我的數據庫中的項目表中選擇最新的行,並顯示標題,描述以及存儲在單獨的項目中的圖像文件夾,但路徑存儲在同一個表中。我可以顯示行,但我的上一個按鈕不起作用,它會轉到第一行。我希望它在每次單擊時移動一行。請幫忙。下面是我的代碼無法在數據庫中逐行移動使用php
<?php
include("scripts/connection.php");
session_start();
if (empty($_SESSION["username"])){
header("Location:login.php");
}
$posts = "SELECT ID, Title, Description, PostDate, Image1, Image2, Image3 FROM items Order By PostDate";
$select = mysql_query($posts);
$numrows = mysql_num_rows($select);
if (isset($_POST['previous'])){
For($i=1,$i>=0,$i--){
mysql_data_seek ($select, $i);
$row=mysql_fetch_assoc($select);
$ID ="$row[ID]";
$title = "$row[Title]";
$datetime = "$row[PostDate]";
$image1 = "$row[Image1]";
$image2 = "$row[Image2]";
$image3 = "$row[Image3]";
$description = "$row[Description]";
}
}else{
while ($row = mysql_fetch_assoc($select)){
$ID ="$row[ID]";
$title = "$row[Title]";
$datetime = "$row[PostDate]";
$image1 = "$row[Image1]";
$image2 = "$row[Image2]";
$image3 = "$row[Image3]";
$description = "$row[Description]";
}
}
?>
感謝您的答覆,但它仍然不能正常工作,當我這樣做,它加載與第一行和當頁我點擊上一個按鈕加載最新帖子 –