0

我一直在尝试在我的数据库中的项目表中选择最新的行,并显示标题、描述以及存储在单独文件夹中但路径存储在同一个表中的项目图像。我可以显示该行,但我之前的按钮不起作用,它转到第一行。我希望每次单击它时它都会向后移动一排。请帮忙。下面是我的代码

<?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]";
}
}
?>
4

1 回答 1

0

尝试按日期降序排序:

$posts = "SELECT ID, Title, Description, PostDate, Image1, Image2, Image3 FROM items Order By PostDate desc  ";
于 2013-10-06T07:41:05.023 回答