<?php //分页的函数 function news($pageNum = 1, $pageSize = 5) { $array = array(); // $coon = mysqli_connect('rm-bp108931c0786t58eko.mysql.rds.aliyuncs.com','jjadmin','jj960820-COM','table_jjf'); $coon = mysqli_connect('localhost','root','96jj0820com','shuju'); mysqli_set_charset($coon, "utf8"); // limit为约束显示多少条信息,后面有两个参数,第一个为从第几个开始,第二个为长度 $rs = "select * from news limit " . (($pageNum - 1) * $pageSize) . "," . $pageSize ; $r = mysqli_query($coon, $rs); while ($obj = mysqli_fetch_object($r)) { $array[] = $obj; } mysqli_close($coon,"table_jjf"); return $array; } //显示总页数的函数 function allNews() { // $coon = mysqli_connect('rm-bp108931c0786t58eko.mysql.rds.aliyuncs.com','jjadmin','jj960820-COM','table_jjf'); $coon = mysqli_connect('localhost','root','96jj0820com','shuju'); mysqli_set_charset($coon, "utf8"); $rs = "select count(*) num from news"; //可以显示出总页数 $r = mysqli_query($coon, $rs); $obj = mysqli_fetch_object($r); mysqli_close($coon,"table_jjf"); return $obj->num; } @$allNum = allNews(); @$pageSize = 5; //约定每页显示几条信息 @$pageNum = empty($_GET["pageNum"])?1:$_GET["pageNum"]; @$endPage = ceil($allNum/$pageSize); //总页数 @$array = news($pageNum,$pageSize); ?>
1. Instruction SQL plus tri Vous pouvez trier par heure ou par ID à incrémentation automatique
2. Je n'ai pas vu votre modèle de site Web et je ne peux pas vous guider pour afficher les informations sur la page