This is not working proper, like if there are 100 page, all no. 1 to 100 is displaying on page
<?php
function paging_1($sql,$vary="record",$width="575")
{
global $limit,$offset,$currenttotal,$showed,$last,$align;
$showed=$offset+$limit;
$last=$offset-$limit;
if(empty($offset))
$offset=0;
$recordset1=mysql_query($sql) or die("Couldn't count total products");
$currenttotal=mysql_num_rows($recordset1);
$pages=$currenttotal%$limit;
if($pages==0)
$pages=$currenttotal/$limit;
else
{
$pages=$currenttotal/$limit;
$pages=(int)$pages+1;
}
for($i=1;$i<=$pages;$i++)
{
$pageoff=($i-1)*$limit;
if($showed==($i*$limit))
break;
}
if($currenttotal>1)$vary.="s";
//echo $width;
//$display="<table width='$width' align='center' border=0><tr><td align='left'><!--Total <b>$currenttotal</b> $vary.</td><td align='center' width='50%'>Displaying Page <b>$i</b> of <b>$pages</b>. ($limit results per page)--></td></tr></table>";
if($currenttotal>0)
echo @$display;
$sql.=" Limit $offset,$limit ";
//echo $sql;
return $sql;
}
function paging_2($str,$width=575)
{
global $currenttotal,$limit,$offset,$showed,$last,$PHP_SELF,$align;
if($currenttotal>0)
{
PAGING STARTS
print "<table border='0' width='$width' cellpadding='2' cellspacing='0' >";
print "<tr>";
print "<td width='10%' align='center'>";
if($offset>=$limit)
print "<a href='$PHP_SELF?offset=$last¤ttotal=$currenttotal&$str'>Previous</a> ";
print "</td>";
//echo "jaijai".$align;
if(isset($align))
{
print "<td align='center' class='bodytext'>
<span class='astro'>Pic:</span> ";
}
else
{
print "<td class='bodytext'>
<span class='astro'>Go to Page:</span> ";
}
$pages=$currenttotal%$limit;
if($pages==0)
$pages=$currenttotal/$limit;
else
{
$pages=$currenttotal/$limit;
$pages=(int)$pages+1;
}
for($i=1;$i<=$pages;$i++)
{
$pageoff=($i-1)*$limit;
if($showed==($i*$limit))
print "<span class'astro'>$i </span> ";
else
print "<a href='$PHP_SELF?offset=$pageoff¤ttotal=$currenttotal&$str' class='bodytext'>$i</a> ";
}
print "</td>";
print "<td width='10%'> <a href='$PHP_SELF?offset=$showed¤ttotal=$currenttotal&$str'>";
if($showed<$currenttotal)
print "Next</a> ";
print "</td>";
print "</tr>";
print "</table><br>";
PAGING ENDS
}
}
?>