<?php
$connect = mysqli_connect('localhost','root','');
$data = mysqli_select_db($connect,'test');
$execc = "select count(*) from user";
$result_execc = mysqli_query($connect,$execc);
$rows = mysqli_fetch_array($result_execc);
$num = $rows[0];
if(empty($_GET['page']))
{
$page = 0;
$page_last=ceil($num/10)-1;
}else
{
$page = $_GET['page'];
if($page<0)$page=0;
if($page<ceil($num/10))$page_last=ceil($num/10)-1;
}
$query = "select * from user limit ".($page*10).",10";
$result = mysqli_query($connect,$query);
while($rec = mysqli_fetch_assoc($result))
{
echo $rec['username']."<br>";
}
for($i=0;$i<=$page_last;$i++)
{
echo "<a href=\"21.php?page=$i\">第{$i}页</a>";
}
?>
$connect = mysqli_connect('localhost','root','');
$data = mysqli_select_db($connect,'test');
$execc = "select count(*) from user";
$result_execc = mysqli_query($connect,$execc);
$rows = mysqli_fetch_array($result_execc);
$num = $rows[0];
if(empty($_GET['page']))
{
$page = 0;
$page_last=ceil($num/10)-1;
}else
{
$page = $_GET['page'];
if($page<0)$page=0;
if($page<ceil($num/10))$page_last=ceil($num/10)-1;
}
$query = "select * from user limit ".($page*10).",10";
$result = mysqli_query($connect,$query);
while($rec = mysqli_fetch_assoc($result))
{
echo $rec['username']."<br>";
}
for($i=0;$i<=$page_last;$i++)
{
echo "<a href=\"21.php?page=$i\">第{$i}页</a>";
}
?>