Initial commit

This commit is contained in:
2025-01-07 17:55:50 +08:00
commit eab1d70061
86 changed files with 2772 additions and 0 deletions

87
20241115/list_72.php Normal file
View File

@ -0,0 +1,87 @@
<meta charset="UTF-8">
<?php
//数据列表 带编辑,新增与删除操作
//引入数据库配置文件
/*
* select * from student_1 limit 0,10
* select * from student_1 limit 10,10
*
*/
require_once "exam_config.php";
//取总记录数
$queryString="select count(name) as maxRows from user_70";
$rs=mysqli_query($link,$queryString);
$row=mysqli_fetch_assoc($rs);
$maxRows=$row['maxRows'];
$rowsOfPage=10;
if(isset($_GET['action'])){
//翻页进入
if($_GET['action']=="top"){
$offset=0;
}
if($_GET['action']=="previous"){
$offset=$_GET['offset']-$rowsOfPage;
if($offset<0){
$offset=0;
}
}
if($_GET['action']=="next"){
$offset=$_GET['offset']+$rowsOfPage;
//处理最后一页的计算逻辑
if($offset>=$maxRows){
$offset=$_GET['offset'];
}
}
if($_GET['action']=='bottom'){
if($maxRows%$rowsOfPage==0){
//整页
$offset=$maxRows-$rowsOfPage;
}else{
//非整页
$offset=$maxRows-$maxRows%$rowsOfPage;
//20 10 20-10 25-25%10 20
}
}
}else{
//第一次进入偏移量为0
$offset=0;
}
$queryString="select * from user_70 limit $offset,$rowsOfPage";
$rs=mysqli_query($link,$queryString);
//用循环语句,从数据集中读出每一条记录
echo "<table border='1'>";
//id,name,password,gender,birthday,course,hometown,resume
echo "<tr><td>学号</td><td>姓名</td><td>班级</td><td>性别</td><td>出生日期</td><td>选课</td><td>籍贯</td><td>操作</td></tr>";
while ($row=mysqli_fetch_assoc($rs)){
/*
echo $row['name'];
echo $row['course'];*/
echo "<tr>";
echo "<td>".$row['name']."</td>";
echo "</tr>";
}
//新增与编辑的差异在于新增是地id没有值而编辑时id有一个值。新增与编辑90%的功能是一样的,因此在实际开发中都是调用的同一个模块
echo "<tr><td colspan='10'>
<a href='edit_5.php?id=&offset=0'>新增</a>
|
<a href='list_72.php?action=top&offset=$offset'>首页</a>
|
<a href='list_72.php?action=previous&offset=$offset'>上一页</a>
|
<a href='list_72.php?action=next&offset=$offset'>下一页</a>
|
<a href='list_72.php?action=bottom&offset=$offset'>尾页</a>
</td></tr>";
echo "</table>";