Page Numbering

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mccommunity
Forum Commoner
Posts: 62
Joined: Mon Oct 07, 2002 8:55 am

Page Numbering

Post by mccommunity »

I have written a script that does page numbering at the top of the page for a catalog. What I would like to do is to make it so there are only 4 pages then tens showing at a time for example say there were 40 pages of data

ex: << 1 | 2 | 3 | 4 .. 10 | 20 | 30 >>

and when you move down the line and click on say 20 the four numbers before it will adjust << 15 | 16 | 17 | 19 .. 20 | 30 | 40 >>

Can someone show me how I need to modify my script to do this? I am very frustrated :) Thanks



Code: Select all

// Set up pagesets for all of the records.

$now_date = date("m-d-Y");
$query2 = "select * from inventory where auction='$SESSION&#1111;auction]'";
 if ($SESSION&#1111;consignor]!='')
 &#123;
 $query2 .= "and consignor='$SESSION&#1111;consignor]'"; 
&#125;
if ($SESSION&#1111;lane]!='')
&#123;
 $query2 .= "and field1='$SESSION&#1111;lane]'";
&#125;
 $query2 .= "AND field2 >= '$now_date'";


if (!$c)&#123;

	$c = pg_connect($runlistdb);

&#125;

$r = pg_exec($c,$query2);

$numrecords = pg_numrows($r);

$pages = $numrecords/$limit;

echo '<p class="nav"><center><table cellpadding=4 ><tr>';
	echo "<td><center><a href="$PHP_SELF?orderby=$orderby&sort=$sort&limit=$limit&offset=0"> << </a>  </center></td> ";
for ($p=0;$p<$pages;$p++)&#123;

	$newoffset = $p*$limit;

	if ($p > 0)&#123;

		echo '  ';

	&#125;

	echo "<td><center><a href="$PHP_SELF?orderby=$orderby&sort=$sort&limit=$limit&offset=$newoffset"> " . ($p+1) . '</a> | </center></td> ';

&#125;
	
	$forwardoffset = $newoffset + $offset;
	echo "<td><center><a href="$PHP_SELF?orderby=$orderby&sort=$sort&limit=$limit&offset=$newoffset"> >> </a>  </center></td> ";
echo '</tr></table></p>';
Post Reply