我试图让我的分页工作,但我有一个问题,“切换之间”页面根本不工作,结果并没有真正起作用。有人可以帮助它让它工作因为我不能让我的生活让它工作,我已经尝试了这么多:/
<?
if (!(isset($pagenum)))
{
$pagenum = 1;
}
$currentpage = 20;
$data_p = mysql_query("SELECT * FROM dogs LIMIT $currentpage") or die(mysql_error());
//This is where you display your query results
while($info = mysql_fetch_array( $data_p ))
{
$id=$info['id'];
echo '<a href="/index.php?dogs='. $id .'">
<img src="/thumbs/'. $id .'.jpg" width="100" height="100" alt="" />
</a>';
echo "<br>";
}
echo "<p>";
// This shows the user what page they are on, and the total number of pages
echo " --Page $pagenum of $last-- <p>";
// First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page.
if ($pagenum == 1)
{
}
else
{
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> ";
echo " ";
$previous = $pagenum-1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> ";
}
//just a spacer
echo " ---- ";
//This does the same as above, only checking if we are on the last page, and then generating the Next and Last links
if ($pagenum == $last)
{
}
else {
$next = $pagenum+1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> ";
echo " ";
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> ";
}
?>
答案 0 :(得分:0)
除非您使用register_globals = on,否则您需要使用$_GET['pagenum']
而不是$pagenum
来获取初始pagenum值