Judul : php pagination script with mysqli
link : php pagination script with mysqli
php pagination script with mysqli
<?php
$con=mysqli_connect("localhost","root","","payroll");
$per_page = 2; //per page record
$pages_query = mysqli_query($con, 'SELECT COUNT(id) FROM employee');
$row = mysqli_fetch_array($pages_query);
$pages = ceil($row[0] / $per_page);
//echo $pages;
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1; //page number throung url
$start = ($page - 1) * $per_page;
$sql="SELECT * FROM employee LIMIT $start, $per_page";
$query = mysqli_query($con,$sql);
while($row=mysqli_fetch_array($query))
{
echo "id is" .$row['id'];
echo $row['name'];
echo $row['phone'];
echo $row['salary'];
echo '<br>';
}
$prev = $page - 1;
$next = $page + 1;
if(!($page<=1))
{
echo "<a href='pag.php?page=$prev'>Prev</a> ";
}
if($pages>=1 && $page<=$pages){
for($x=1;$x<=$pages;$x++){
echo ($x == $page) ? '<strong><a href="?page='.$x.'">'.$x.'</a></strong> ' : '<a href="?page='.$x.'">'.$x.'</a> ';
}
}
if(!($page>=$pages))
{
echo "<a href='pag.php?page=$next'>Next</a>";
}
?>
$con=mysqli_connect("localhost","root","","payroll");
$per_page = 2; //per page record
$pages_query = mysqli_query($con, 'SELECT COUNT(id) FROM employee');
$row = mysqli_fetch_array($pages_query);
$pages = ceil($row[0] / $per_page);
//echo $pages;
$page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1; //page number throung url
$start = ($page - 1) * $per_page;
$sql="SELECT * FROM employee LIMIT $start, $per_page";
$query = mysqli_query($con,$sql);
while($row=mysqli_fetch_array($query))
{
echo "id is" .$row['id'];
echo $row['name'];
echo $row['phone'];
echo $row['salary'];
echo '<br>';
}
$prev = $page - 1;
$next = $page + 1;
if(!($page<=1))
{
echo "<a href='pag.php?page=$prev'>Prev</a> ";
}
if($pages>=1 && $page<=$pages){
for($x=1;$x<=$pages;$x++){
echo ($x == $page) ? '<strong><a href="?page='.$x.'">'.$x.'</a></strong> ' : '<a href="?page='.$x.'">'.$x.'</a> ';
}
}
if(!($page>=$pages))
{
echo "<a href='pag.php?page=$next'>Next</a>";
}
?>
Demikianlah Artikel php pagination script with mysqli
Sekianlah artikel php pagination script with mysqli kali ini, mudah-mudahan bisa memberi manfaat untuk anda semua. baiklah, sampai jumpa di postingan artikel lainnya.
Anda sekarang membaca artikel php pagination script with mysqli dengan alamat link https://othereffect.blogspot.com/2018/05/php-pagination-script-with-mysqli.html
0 Response to " php pagination script with mysqli"
Post a Comment