Re: paging of records

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

The example code of pagination 

/* Page wise Code Start */

    $perpage=0;
    $itemNo=0;
    $pageNo=0;
	$nextPages=0;
	$previousPage=0;
	$nextViewPage=0;

	$pageDetail='';
	$preview='';
	$nextView='';
	$pageLink='';

    $perpage=50;
	if($value['page']=="")
		$value['page']=0;
	$itemNo=($value['page']*$perpage);

    $query1 = "SELECT * FROM article_submit_details
where article_approve=0 and
categoryID=".$value["catId"];
    $db->query($query1);
	$rows=$db->resultCount();
    //echo "rows=$rows<br>";
    $pageNo=ceil($rows/$perpage);

    $NotApprovedArticleArray=array();
	$que1="select * from article_submit_details where
article_approve=0 and categoryID=".$value["catId"]."
order by article_date asc limit $itemNo,$perpage";
	//echo "que1=$que1<br>";
    $db->query($que1);
    while($db->fetchRow()) {
		$myArrString='';
	 
$myArrString=$db->record["id"]."|".$db->record["article_title"]."|".$db->record["author_name"]."|".$db->record["article_date"];
        array_push ($NotApprovedArticleArray,
$myArrString);
    }
	$db->clear();

	  	for($j=1;$j<=$pageNo;$j++)
		{
		    if($value['page']==$j-1)
			{

 			   if ($value['page']>0){
				  $previousPage=$j-2;
                  $preview .="<a
href=\"articleView.php?page=$previousPage&m=wtapproval&catId=$value[catId]\"><strong>Previous
 </strong></a>";
			   }
               $pageLink .="<font
color=\"#FF0000\"><strong>$j</strong></font>";
 			   if ($j<($pageNo)){
				  $nextViewPage=$j;
                  $nextView .="<a
href=\"articleView.php?page=$nextViewPage&m=wtapproval&catId=$value[catId]\"><strong>
 Next</strong></a>";
			   }
			}
		    else
			{
			   $nextPages=$j-1;
               $pageLink .="<a
href=\"articleView.php?page=$nextPages&m=wtapproval&catId=$value[catId]\"><strong>$j</strong></a>";
			}
		 }
        if ($rows>0){
			$pageDetail .="<B>Page :</B>&nbsp;&nbsp;";
			$pageDetail .=$preview;
			$pageDetail .=$pageLink;
			$pageDetail .=$nextView;
        }
		echo "$pageDetail";
/* Page wise Code End */

Regards,
Atin

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 





PHP Data object relational mapping generator - http://www.meta-language.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux