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章 系统测试
数据库:
-- ---------------------------- 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');
控制器:
<?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('删除失败'); } } }