//Paging function
function news($pageNum = 1, $pageSize = 5)
{
$array = array();
$coon = mysqli_connect('localhost',' root','96jj0820com','shuju');
mysqli_set_charset($coon, "utf8");
// limit is how many pieces of information are displayed for the constraint, followed by two parameters, The first is the starting number, the second is the length
$rs = "select * from case limit " . (($pageNum - 1) * $pageSize) . "," . $pageSize ;
$r = mysqli_query($coon, $rs);
while ($obj = mysqli_fetch_object($r)) {
$array[] = $obj ;
}
mysqli_close($coon,"shuju");
return $array;
}
//Display Function of total number of pages
function allNews()
{
$coon = mysqli_connect('localhost','root','96jj0820com','shuju');
mysqli_set_charset($coon, "utf8");
$rs = "select count(*) num from case"; //The total number of pages can be displayed
$r = mysqli_query($coon, $rs);
$obj = mysqli_fetch_object($r);
mysqli_close($coon,"shuju");
return $obj->num;
}
@$allNum = allNews();
@$pageSize = 5; //Agree how many pieces of information are displayed on each page
@$pageNum = empty($_GET["pageNum"])?1:$_GET["pageNum"];
@$endPage = ceil($allNum/$pageSize); / /total pages
@$array = array_reverse(news($pageNum,$pageSize));
?>
foreach($array as $key=>$value){
echo "
echo "
";echo "
}
?>