This is for a school project this page displays a table which is split into sections of 15 per page, however at the bottom of the table their are the numbers on which page to go to.
My table has 862450 rows meaning there is 57408 numbers shown at the bottom. How would do i limit this to 5 numbers so it looks like this
<< 12345 >>
Any help is greatly appreciated thanks!
<div class="container mt-4">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h4>List of Regulated Pools
</h4>
<div class="btn-group">
<a href="Databaseone.php" class="btn btn-primary active" aria-current="page"> Regulated Pool Register</a>
<a href="Databasetwo.php" class="btn btn-primary">Certified Safety Pools</a>
<a href="Databasethree.php" class="btn btn-primary">Registered Pool Inspectors</a>
</div>
</div>
<div class="card-body">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>ID</th>
<th>Site Name</th>
<th>Unit Number</th>
<th>Street Number</th>
<th>Street Name</th>
<th>Street Type</th>
<th>Suburb</th>
<th>Post Code</th>
<th>Nubmer of Pools</th>
<th>Local Goverment Authority</th>
<th>Shared Pool</th>
</tr>
</thead>
<tbody>
<?php
require('conn.php');
$num_per_page=15;
if(isset($_GET["page"]))
{
$page=$_GET["page"];
}
else
{
$page=1;
}
$start_from=($page-1)*15;
$query="select * from norm_pool limit $start_from,$num_per_page";
$result= mysqli_query($conn, $query);
if(mysqli_num_rows($result) > 1 )
{
while($row = $result->fetch_assoc())
{
?>
<tr>
<td><?= $row['ID']; ?></td>
<td><?= $row['sitename']; ?></td>
<td><?= $row['unitno']; ?></td>
<td><?= $row['streetno']; ?></td>
<td><?= $row['streetname']; ?></td>
<td><?= $row['streettype']; ?></td>
<td><?= $row['suburb']; ?></td>
<td><?= $row['postcode']; ?></td>
<td><?= $row['noofpools']; ?></td>
<td><?= $row['localgovauth']; ?></td>
<td><?= $row['sharedpool']; ?></td>
</tr>
<?php
}
}
else
{
echo "<h5> No Users Found </h5>";
}
?>
</tbody>
</table>
<?php
require('conn.php');
$query='select * from norm_pool';
$result= mysqli_query($conn, $query);
$total_records=mysqli_num_rows($result);
$total_pages=ceil($total_records/$num_per_page);
for($i=1;$i<=$total_pages;$i++)
{
echo "<a href='Databaseone.php?page=".$i."'>".$i."</a>";
}
?>
</div>
</div>
</div>
</div>
</div>
I have tried multiple solutions and none have had any success as all the solutions have very different code to mine
2
Answers
here is one way to do it
please have a look at the code below:
Result:(I believe as you are using bootstrap hence i added some )
To limit the numbers shown in the pagination, you can use the concept of "ellipsis" or "dots" to indicate that there are more pages available beyond what is currently displayed. Here are some steps you can follow:
For example, let’s say you want to display a maximum of 5 pages at any given time, and you’re currently on page 10 out of a total of 20 pages. The pagination would display something like this:
1 2 … 9 10 11 … 19 20
The ellipsis indicates that there are more pages available beyond what is currently displayed, and when the user clicks on it, the pagination updates to display the next set of pages.