IT Community - Software Programming, Web Development and Technical Support

Paging array in PHP

This is a discussion on Paging array in PHP within the PHP Programming forums, part of the Web Development category; Initial steps for Paging $num =count($results->products); // number of items in list $per_page = 10; // Number of items to ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-16-2007, 11:11 PM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Paging array in PHP

Initial steps for Paging


$num =count($results->products); // number of items in list
$per_page = 10; // Number of items to show per page
$showeachside = 5 ;// Number of items to show either side of selected page

if(empty($start))$start=0; // Current start position

$max_pages = ceil($num / $per_page); // Number of pages
$cur = ceil($start / $per_page)+1; // Current page number
// give the user a nice message about the results
echo" <td width='1' align='left' valign='top'><img src='images/img_vr_line.gif' height='57' /></td>



Iterates through the list of items



for($x=$start;$x<min($num,($start+$per_page)+1);$x ++)
{


Display like <1 2 3 >
<td align="right" valign="top" background="images/bg_footer.gif"><table width="50%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="146" align="left" valign="middle">&nbsp;</td>
<td width="164" align="left" valign="middle" class="selected">
Page
<?php
$eitherside = ($showeachside * $per_page);
if($start+1 > $eitherside)print (" .... ");
$pg=1;
for($y=0;$y<$num;$y+=$per_page)
{
$class=($y==$start)?"pageselected":"";
if(($y > ($start - $eitherside)) && ($y < ($start + $eitherside)))
{
?>
&nbsp;<a class="<?php print($class);?>" href="<?php print("$thispage".($y>0?("start=").$y:""));?>"><?p hp print($pg);?></a>&nbsp;
<?php
}
$pg++;
}
if(($start+$eitherside)<$num)print (" .... ");
?>
</td>
<td width="30" align="left" valign="middle">
<?php
if($start+$per_page<$num)
{
?>
<a href="<?php print("$thispage start=".max(0,$start+$per_page));?>"><img src="images/img_next.gif" height="22" border="0" usemap="#Map2" /></a>
<?php
}
?>
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paging in Grid Kirubhananth ASP and ASP.NET Programming 8 11-28-2008 01:51 AM
Paging Concept in Repeater? poornima ASP and ASP.NET Programming 1 03-21-2008 09:48 PM
What’s the difference between the System.Array.CopyTo() and System.Array.Clone() ? Archer C# Programming 2 08-25-2007 03:00 AM
Wt mean by paging? prasath Operating Systems 1 07-19-2007 05:08 AM
ASP with paging elements kingmaker HTML, CSS and Javascript Coding Techniques 1 07-19-2007 12:32 AM


All times are GMT -7. The time now is 04:39 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0