我为我的网站创建分页(它不完整,但只是我认为最重要的部分),一切都运行良好,但它显示最旧的帖子意味着最老的帖子...但我需要最新的帖子在我的分页的第一页顶部
这是我的分页脚本
include('mysql.php');
$tbl_name="posts";
$adjacents = 3;
/*
First get total number of rows in data table.
*/
$query = "SELECT COUNT(*) as num FROM posts";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
/* Setup vars for query. */
$targetpage = "index.php";
$limit = 6;
$page = $_GET['page'];
if($page)
$start = ($page - 1) * $limit;
else
$start = 3;
/* Get data. */
$sql = "SELECT * FROM posts LIMIT $start, $limit";
$result = mysql_query($sql);
/* Setup page vars for display. */
if ($page == 0) $page = 1;
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total_pages/$limit);
$lpm1 = $lastpage - 1;
当我使用
时 $result = mysql_safe_query('SELECT * FROM posts ORDER BY date DESC');
它将显示从最新到最旧的帖子,但分页将失败
我还在学习php,所以对于每个建议或解决方案都非常感谢