myfafa wrote:Dear FlyingBeyond
i did what you said but nothing change again๐
i added lines 3,4,5,6,7 IN:
I test your code and made several changes such as adding , deleting , and changing.Now ,all is OK , I post the code here and I also upload the three files.Remember to download the attachment.
so , have fun ,myfafa !๐
mainpage
<?php
include("connection.php");
$page = $_GET['page']; // add this line !
if(!isset($page))
$page=1;
$path = $_SERVER['PHP_SELF'];
$path = basename("$path");
//$path = $path . '?page=' . $page; // delete this line
$query="select count(*) as total from category";
$result = mysql_query($query) or die(mysql_error());
$line=mysql_fetch_assoc($result);
$total=$line['total'];
require('header.php');
echo "<hr>";
$query="select * from category order by name DESC limit $querybegin,$onepagelist";
$result = mysql_query($query) or die("Query failed : " . mysql_error());
for($i=0;$line=mysql_fetch_assoc($result);$i++)
{
echo $line['name']."</br>";
}
echo "<hr>";
require('footer.php');
?>
headerpage
<?php
//$total=0; // the error~~~~, this line should be deleted
$onepagelist=10; // change the value to accommodate your need
if(!isset($page))
$page=1;
if($total%$onepagelist==0)
$pagenum=$total/$onepagelist;
else
$pagenum=(int)($total/$onepagelist)+1;
$lastpage=$page-1;
$nextpage=$page+1;
$querybegin=($page-1)*$onepagelist;
?>
footerpage
<?php
if($pagenum>1)
{
if($page<=1)
echo "TOTAL ".$pagenum." Pages Current page ".$page." First|Previous|<a href='".$path."?page=".$nextpage."' target='_self'>Next</a>|<a href='".$path."?page=".$pagenum."' target='_self'>Final</a>";
elseif($page>=$pagenum)
echo "TOTAL ".$pagenum." Pages Current page ".$page." <a href='".$path."?page=1' target='_self'>First</a>|<a href='".$path."?page=".$lastpage."' target='_self'>Previous</a>|Next|Final";// 'first' in this line shoud be 'previous '
else
echo "TOTAL ".$pagenum." Pages Current page ".$page." <a href='".$path."?page=1' target='_self'>First</a>|<a href='".$path."?page=".$lastpage."' target='_self'>Previous</a>|<a href='".$path."?page=".$nextpage."' target='_self'>Next</a>|<a href='".$path."?page=".$pagenum."' target='_self'>Final</a>";
}
else
echo "Total:1 page Current Page:1 First|Previous|Next|Final";
?>