PHP网页设计作业,基于ThinkPHP5的图书管理系统

1章 开发环境搭建

1.1 Window10系统的PC

1.2 集成环境phpstudy

1.3 php7.3.4

1.4 mysql 5.5.29

数据库管理工具:phpmyadmin

数据库连接配置

3章 图书管理功能的实现

3.1 功能设计

3.2 概要设计

3.3详细设计

3.3.1用户界面逻辑设计

3.3.2 数据库的设计

3.3.3应用的交互逻辑

3.4 本章小结

4章 系统实现

5 系统测试

数据库:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-- ----------------------------
DROP TABLE IF EXISTS `book`;
CREATE TABLE `books` (
`id` int(8) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`category` varchar(50) NOT NULL,
`price` decimal(10, 2) DEFAULT NULL,
`publish_time` date DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=20 DEFAULT CHARSET=utf8;
 
-- ----------------------------
-- Records of books
-- ----------------------------
INSERT INTO `books` VALUES ('1', 'PHP从入门到精通', 'PHP', '50.00', '2017-02-17');
INSERT INTO `books` VALUES ('2', 'PHP自学宝典', 'PHP', '69.00', '2017-02-17');
INSERT INTO `books` VALUES ('3', 'PHP项目实战入门', 'PHP', '70.00', '2017-02-17');
INSERT INTO `books` VALUES ('4', '零基础学PHP', 'PHP', '68.80', '2017-02-17');

  

 控制器:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
 
namespace app\index\controller;
 
use think\Controller;
use think\Request;
use think\Db;
 
class Index extends Controller
{
public function index()
{
$where = '';
$keywords = input('keywords');
if ($keywords) { //组装搜索条件
$where = " name like '%{$keywords}%'";
}
 
$list = Db::name('books')->where($where)->order('id desc')->paginate(2);
// 把分页数据赋值给模板变量list
$page = $list->render();
$this->assign('list', $list);
$this->assign('page', $page);
$this->assign('keywords', $keywords);
// 把分页数据赋值给模板变量list
// 不带任何参数 自动定位当前操作的模板文件
return $this->fetch();
}
 
public function add()
{
return $this->fetch();
}
 
public function adddo()
{
$data = input('post.'); //接收前台表单数据
$add = Db::name('books')
->data($data)
->insert(); //通过insert添加
if ($add) {
$this->success('添加成功', url('index/index')); //操作成功提示并跳转
} else {
$this->error('修改失败');
}
}
 
public function edit()
{
$id = input('id');
$result = Db::table('books')->where('id', $id)->find();
 
$this->assign('data', $result);
return $this->fetch();
}
 
public function editDo()
{
$data = input('post.');
 
$update = Db::name('books')
->where('id', $data['id'])
->update($data); //通过update修改
if ($update) {
$this->success(
'修改成功',
url('index/index') //操作成功提示并跳转
);
} else {
$this->error('修改失败');
}
}
 
public function delDo()
{
$id = input('id');
$delete = Db::table('books')->where('id', $id)->delete();
if ($delete) {
$this->success(
'删除成功',
url('index/index') //操作成功提示并跳转
);
} else {
$this->error('删除失败');
}
}
}

  

源码下载:https://www.zuoyewo.com/goods-85.html?cnblog

posted @   JUSTKK  阅读(515)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示