diff --git a/app/Views/history/history.php b/app/Views/history/history.php
index 810779df9c5beccde0873d6ad8260662e014465f..b2e02634119d3edb062c656a5cdf4a3e41ac6c9d 100644
--- a/app/Views/history/history.php
+++ b/app/Views/history/history.php
@@ -25,7 +25,9 @@
     } else {
         $pembelians = $pembelianController->getAllPembelianWithDetails();
     }
-    $paginationData = $pembelianController->paginateHistory($pembelians);
+    $pageSize = isset($_GET['pageSize']) ? $_GET['pageSize'] : 10; 
+
+    $paginationData = $pembelianController->paginateHistory($pembelians,$_GET['page'],$pageSize);
     $pembelians = $paginationData['pembelian'];
     $totalEvents = $paginationData['total'];
     $currentPage = $paginationData['page'];
@@ -61,18 +63,30 @@
             endforeach;?>
         </div>
         <div class="pagination">
-            <?php if ($currentPage > 1) : ?>
-                <a href="?page=<?= $currentPage - 1 ?>">Previous</a>
-            <?php endif; ?>
-            
-            <?php for ($i = 1; $i <= $maxPage; $i++) : ?>
-                <a href="?page=<?= $i ?>" <?= ($i == $currentPage) ? 'class="active"' : '' ?>><?= $i ?></a>
-            <?php endfor; ?>
-
-            <?php if ($currentPage < $maxPage) : ?>
-                <a href="?page=<?= $currentPage + 1 ?>">Next</a>
-            <?php endif; ?>
-        </div>
+                <?php
+                $searchParams = [
+                    'search' => $searchQuery,
+                    'min_stock' => $minStock,
+                    'sort' => $sortKey,
+                    'pageSize' => $pageSize, // Include page size
+                ];
+
+                $maxButtons = 5;  // Maximum number of pagination buttons to display
+                $halfMaxButtons = floor($maxButtons / 2);
+
+                if ($currentPage > 1) : ?>
+                    <a href="?page=<?= $currentPage - 1 ?>">Previous</a>
+                <?php endif; ?>
+
+                <?php
+                for ($i = max(1, $currentPage - $halfMaxButtons); $i <= min($maxPage, $currentPage + $halfMaxButtons); $i++) : ?>
+                    <a href="?page=<?= $i ?>" <?= ($i == $currentPage) ? 'class="active"' : '' ?>><?= $i ?></a>
+                <?php endfor; ?>
+
+                <?php if ($currentPage < $maxPage) : ?>
+                    <a href="?page=<?= $currentPage + 1 ?>">Next</a>
+                <?php endif; ?>
+            </div>
 
     </div>
 
diff --git a/app/Views/home/home.php b/app/Views/home/home.php
index b0871af0d1c7a97853a3f1790cd1beee7398f735..701666b3ed1ed21f2fa786cc27dd08f05d741bf5 100644
--- a/app/Views/home/home.php
+++ b/app/Views/home/home.php
@@ -28,7 +28,9 @@
     if (!isset($_GET['page'])) {
         $_GET['page'] = 1;
     }
-    $paginationData = $eventController->paginateEvents($searchResults,$_GET['page']);
+    $pageSize = isset($_GET['pageSize']) ? $_GET['pageSize'] : 10; 
+
+    $paginationData = $eventController->paginateEvents($searchResults,$_GET['page'],$pageSize);
     $events = $paginationData['events'];
     $totalEvents = $paginationData['total'];
     $currentPage = $paginationData['page'];
@@ -81,18 +83,32 @@
             endforeach;?>
 
             <div class="pagination">
-                <?php if ($currentPage > 1) : ?>
-                    <a href="?page=<?= $currentPage - 1 ?>">Previous</a>
+                <?php
+                $searchParams = [
+                    'search' => $searchQuery,
+                    'min_stock' => $minStock,
+                    'sort' => $sortKey,
+                    'pageSize' => $pageSize, // Include page size
+                ];
+
+                $maxButtons = 5;  // Maximum number of pagination buttons to display
+                $halfMaxButtons = floor($maxButtons / 2);
+
+                if ($currentPage > 1) : ?>
+                    <a href="?page=<?= $currentPage - 1 . '&' . http_build_query($searchParams) ?>">Previous</a>
                 <?php endif; ?>
-                
-                <?php for ($i = 1; $i <= $maxPage; $i++) : ?>
-                    <a href="?page=<?= $i ?>" <?= ($i == $currentPage) ? 'class="active"' : '' ?>><?= $i ?></a>
+
+                <?php
+                for ($i = max(1, $currentPage - $halfMaxButtons); $i <= min($maxPage, $currentPage + $halfMaxButtons); $i++) : ?>
+                    <a href="?page=<?= $i . '&' . http_build_query($searchParams) ?>" <?= ($i == $currentPage) ? 'class="active"' : '' ?>><?= $i ?></a>
                 <?php endfor; ?>
-        
+
                 <?php if ($currentPage < $maxPage) : ?>
-                    <a href="?page=<?= $currentPage + 1 ?>">Next</a>
+                    <a href="?page=<?= $currentPage + 1 . '&' . http_build_query($searchParams) ?>">Next</a>
                 <?php endif; ?>
             </div>
+
+
         </div>
     </div>