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

3
20241115/exam_config.php Normal file
View File

@ -0,0 +1,3 @@
<?php
$link=mysqli_connect('localhost','user_20241115_58056','K6UJKaRLiipvw','exam_20241115_58056');
mysqli_query($link,'set names utf8');

15
20241115/exam_setup.php Normal file
View File

@ -0,0 +1,15 @@
<?php
require_once "exam_config.php";
//先删除在创建
mysqli_query($link,"drop table user_70");
$queryString="create table user_70(name char(50),address char(50),password char(50))ENGINE=MyISAM DEFAULT CHARSET=utf8";
mysqli_query($link,$queryString);
echo mysqli_error($link)."<br>";
$queryString="insert into user_70(name,address,password)values('mike','shanghai','c4ca4238a0b923820dcc509a6f75849b')";
mysqli_query($link,$queryString);
echo mysqli_error($link)."<br>";
$queryString="insert into user_70(name,address,password)values('rose','beijing','c4ca4238a0b923820dcc509a6f75849b')";
mysqli_query($link,$queryString);
echo mysqli_error($link)."<br>";

27
20241115/form_test_1.php Normal file
View File

@ -0,0 +1,27 @@
<meta charset="UTF-8">
<?php
//里程碑 拿到浏览器提交的数据,数据重现(现场恢复) 无状态协议模式 stateless
//实现单选,复选,下拉框的数据重现
if(isset($_POST['ok'])){
//单选按钮与复选框在用户没有操作的情况下不会提交默认值到服务器,因此需要单独做逻辑处理
//var_dump($_POST);
echo $_POST['name'];
echo $_POST['age'];
$name=$_POST['name'];
$age=$_POST['age'];
}else{
$name="姓名不能为空";
$age = "";
}
?>
<form action="" method="post">
姓名:<input type="text" id="name" name="name" value="<?php echo $name;?>"><br>
年龄:<input type="text" id="age" name="age" value="<?php echo $age;?>"><br></br>
<br>
<input type="submit" id="ok" name="ok" value="ok">
</form>
<script>
</script>

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>";

View File

@ -0,0 +1,4 @@
<?php
$link=mysqli_connect("localhost",'user_20241115_58056','K6UJKaRLiipvw','exam_20241115_58056');
mysqli_query($link,"set names utf8");
var_dump($link);

View File

@ -0,0 +1 @@
6rlWseYg4VDRzwkAjLo

38
20241115/upload_1.php Normal file
View File

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>文件上传</title>
</head>
<body>
<h2>文件上传表单</h2>
<!-- 文件上传表单 -->
<form action="" method="post" enctype="multipart/form-data">
<input type="file" id="my_upload_file" name="my_upload_file" required>
<br><br>
<input type="submit" id="ok" name="ok" value="上传文件">
</form>
<?php
// 处理文件上传
if (isset($_POST['ok'])) {
// 检查是否选择了文件
if (isset($_FILES['my_upload_file']) && $_FILES['my_upload_file']['error'] == 0) {
$uploadDir = 'upload/'; // 文件上传目录
$fileName = basename($_FILES['my_upload_file']['name']); // 获取文件名
$targetFilePath = $uploadDir . $fileName; // 文件保存路径
// 移动上传的文件到指定目录
if (move_uploaded_file($_FILES['my_upload_file']['tmp_name'], $targetFilePath)) {
echo "<p>文件上传成功!文件路径:<a href='$targetFilePath'>$targetFilePath</a></p>";
} else {
echo "<p>文件上传失败,请重试。</p>";
}
} else {
echo "<p>未选择文件或文件上传出错。</p>";
}
}
?>
</body>
</html>

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>main</title>
</head>
<body>
</body>
</html>
<?php
?>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>config</title>
</head>
<body>
</body>
</html>
<?php

10
20241115/www/display.html Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>display</title>
</head>
<body>
<a href="list.html">list</a>
</body>
</html>

10
20241115/www/index.html Normal file
View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>index</title>
</head>
<body>
<a href="list.html">list</a>
</body>
</html>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>class</title>
</head>
<body>
</body>
</html>
<?php

11
20241115/www/list.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>list</title>
</head>
<body>
<a href="display.html">显示</a>
<a href="index.html">返回</a>
</body>
</html>