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 ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| 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"> </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))) { ?> <a class="<?php print($class);?>" href="<?php print("$thispage".($y>0?("start=").$y:""));?>"><?p hp print($pg);?></a> <?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 } ?> |
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | |
| |
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 |