SEO | Website Design | Web development
Community forum for Expert Assistance!
SEO Forum - Web Design : Web Hosting : Web Development : SEO Forum » ASP programming
»navigate pages generated from the select query
Reply to topic Page 1 of 1
navigate pages generated from the select query
Author Message
Reply with quote
Post navigate pages generated from the select query 
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 )&nbsp; &nbsp;&nbsp; ";
if($page>1 ){
echo "<a class=$class href='".selfq()."&page=".($page-1)."'> &lt;&lt;Previous </a>";
}
$next=$page+1;
if($next <=$totalpages ){

echo "&nbsp;&nbsp;&nbsp;<a class=$class href='".selfq()."&page=".$next."'> Next &gt;&gt; </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>";

}
}




?>
[url=http://www.hanusoftware.com]Software Development India[/url]


_________________
[url=http://www.hanusoftware.com]Offshore Software Development Company India[/url]
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:
SEO Forum - Web Design : Web Hosting : Web Development : SEO Forum » ASP programming
»navigate pages generated from the select query


 
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  


SEO Services |Search Engine Optimization |SEO Forum | Web Design | Web Development | Office Cleaning Atlanta |SEO Marketing forum |Website Design forum |Web Hosting discussion |SEO Marketing |Promotional Products Grant writing workshops | SEO Marketing | Mahjong Games | Promotional Items | CLEP Exam | New homes Dallas | Paintball | New homes Houston | Paintball | Top social networking websites | Caribbean Villas Rental | Build your website Free |Mahjong| Grant Writing Seminars | Dvla Number Plates