Hello phmasters, any idea po sa mga programmer dyan about pagination limit?
Nagana naman ang pagination na ginawa ko, pero hindi ako satisfy,
Ang current na output ko kasi is: Prev 1 2 3 4 5 6 7 8 9 10 11 12 Next.
Ang gusto kong mangyari is : Prev 1 2 3 4 5...10 Next.
Tulad sa comment section natin dito naka limit ang pagination,
Ito po ang current code ko:
$numperpage = 100;
$countsql = $database->prepare("SELECT COUNT(no) from inv_salesreport ");
$countsql->execute();
$row = $countsql->fetch();
//echo "Total numbers of records is ".$row[0];
$numrecords = $row[0];
$numlinks =ceil($numrecords/$numperpage);
$page = $_GET['page'];
if ($page==1){
$start = 1;
}else{
$numperpage = $page*$numperpage;
$start = 100*$page-99;
}
$stmt = $database->prepare("SELECT e.*
FROM (SELECT e.*, row_number() over (ORDER BY no ASC) as seqnum
FROM inv_salesreport e) e WHERE seqnum between :start and :numperpage;");
$stmt->bindParam(':start',$start);
$stmt->bindParam(':numperpage',$numperpage);
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_OBJ); //PDO::FETCH_ASSOC
$result = $stmt->fetchAll();
<nav arial-label="Page navigation example">
<ul class="pagination mt-5">
<li class="page-item"><a class="page-link <?php if($_GET['page']==1){ ?> disabled <?php }?>" href="<?php echo "export_salesreport2.php?page=".$page-1; ?>">Previous</a></li>
<?php
//$numperpage * $start;
for ($i=1; $i <=$numlinks ; $i++) {
//$y = $i+1;
?>
<li class="page-item"><a class="page-link" href="<?php echo "export_salesreport2.php?page=".$i; ?>"><?php echo $i; ?></a></li>
<?php } ?>
<li class="page-item"><a class="page-link <?php if($_GET['page']==$numlinks){ ?> disabled <?php }?>" href="<?php echo "export_salesreport2.php?page=".$page+1; ?>">Next</a></li>
</ul>
</nav>
by the way, I'm using PDO PHP and MS SQL gamit kong DB.
Sana may makatulong
Nagana naman ang pagination na ginawa ko, pero hindi ako satisfy,
Ang current na output ko kasi is: Prev 1 2 3 4 5 6 7 8 9 10 11 12 Next.
Ang gusto kong mangyari is : Prev 1 2 3 4 5...10 Next.
Tulad sa comment section natin dito naka limit ang pagination,
Ito po ang current code ko:
$numperpage = 100;
$countsql = $database->prepare("SELECT COUNT(no) from inv_salesreport ");
$countsql->execute();
$row = $countsql->fetch();
//echo "Total numbers of records is ".$row[0];
$numrecords = $row[0];
$numlinks =ceil($numrecords/$numperpage);
$page = $_GET['page'];
if ($page==1){
$start = 1;
}else{
$numperpage = $page*$numperpage;
$start = 100*$page-99;
}
$stmt = $database->prepare("SELECT e.*
FROM (SELECT e.*, row_number() over (ORDER BY no ASC) as seqnum
FROM inv_salesreport e) e WHERE seqnum between :start and :numperpage;");
$stmt->bindParam(':start',$start);
$stmt->bindParam(':numperpage',$numperpage);
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_OBJ); //PDO::FETCH_ASSOC
$result = $stmt->fetchAll();
<nav arial-label="Page navigation example">
<ul class="pagination mt-5">
<li class="page-item"><a class="page-link <?php if($_GET['page']==1){ ?> disabled <?php }?>" href="<?php echo "export_salesreport2.php?page=".$page-1; ?>">Previous</a></li>
<?php
//$numperpage * $start;
for ($i=1; $i <=$numlinks ; $i++) {
//$y = $i+1;
?>
<li class="page-item"><a class="page-link" href="<?php echo "export_salesreport2.php?page=".$i; ?>"><?php echo $i; ?></a></li>
<?php } ?>
<li class="page-item"><a class="page-link <?php if($_GET['page']==$numlinks){ ?> disabled <?php }?>" href="<?php echo "export_salesreport2.php?page=".$page+1; ?>">Next</a></li>
</ul>
</nav>
by the way, I'm using PDO PHP and MS SQL gamit kong DB.
Sana may makatulong
Attachments
-
You do not have permission to view the full content of this post. Log in or register now.