![]() |
|
|||||||
| Register | FAQ | Members List | Downloads | Calendar | Today's Posts | Search | Webmaster Resources | Webmaster Blogs |
![]() UK Web Hosting |
![]() Website Hosting |
![]() UK One Way |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
Mentioned below is a PHP function , which can be used to navigate pages generated from the select query . ie. in the form of << Previous || Next >>
<? function PagerNextPrevious(&$sql,$pagesize,$class='txt'){ // Set Default Page Size to 20 if($pagesize=="") $pagesize=20; $page=get_post('page'); if($page!='NA'){ $beg=($page-1)*$pagesize; $end=$pagesize; }else{ $beg=0; $end=$pagesize; $page=1; } $rs=mysql_query($sql) ; $nrows=mysql_num_rows($rs); $sql=$sql." limit $beg,$end"; $rs=mysql_query($sql); $subrows=mysql_num_rows($rs); if($nrows!=0){ $from=(int)($beg)+1; $totalpages=(int)($nrows/$pagesize); $frac=($nrows/$pagesize); if(($frac-$totalpages)>0) $totalpages+=1; echo "( Page $page of $totalpages ) "; if($page>1 ){ echo "<a class=$class href='".selfq()."&page=".($page-1)."'> <<Previous </a>"; } $next=$page+1; if($next <=$totalpages ){ echo " <a class=$class href='".selfq()."&page=".$next."'> Next >> </a>"; } } } // Assuming you have Opened connection to mysql database. $sql=" Select * from Products "; // Show the pager link in form of Previous||Next PagerNextPrevious($sql,20,'text'); $rs=mysql_query($sql); if(mysql_num_rows($rs)>0){ while($row=mysql_fetch_array($rs)){ echo $row["ProductName"]."<br>"; } } ?> |
|
|||||
|
Hanussoftware, thanks for that, I will add to your reputation after you introduce yourself at the intro forum which can be found here: http://forums.ukwebmasterworld.com/n...-introduction/ but thanks for that code snippet
![]()
__________________
* Build a shopping cart for your business with eCommerce software UK * BossCart.com can build you a Bespoke shopping cart :: Add Eco sites to The Green Directory free of charge. |
![]() |
| Bookmarks |
| Webmaster Resources |
| • UK Web Hosting • UK WW SEO Tools • Free site submission • Web Directory |
| Advertisement |
![]() |
| Site Of the Month |
![]() Nominate site of the month |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PAGERANK retrieval = automated query | maxseo | Webmaster Toolbox | 1 | 02-22-2007 06:11 AM |
| UK Webmaster World Forums - Internet marketing, web development, domain names, SEO contest and discussuons. |
| Subscribe to our feeds |