1 Star 0 Fork 0

武陵人/Library

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
LendBook.php 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
武陵人 提交于 2017-03-06 01:20 . change at home
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2017/3/3
* Time: 15:21
*
*
*/
function LendBook(){
echo "请您输入书号:";
$book_id = trim(fgets(STDIN));
echo "请输入学号:";
$number = trim(fgets(STDIN));
echo "请输入您的姓名:";
$reader_name = trim(fgets(STDIN));
echo "请输入书名:";
$book_name = trim(fgets(STDIN));
//连接数据库
$dsn = 'mysql:dbname=school;host=192.168.137.2';
$user = 'root';
$password = '123456';
$db = new PDO($dsn, $user, $password);
try {
$aaa = $db->exec("insert into record (rid,bid,rname,bname)VALUES
('$number','$book_id','$reader_name','$book_name')");
if ($aaa) {
echo "语句对了\n";
} else if ($aaa === false) {
echo "语句出错\n";
} else {
echo "内容为空,请联系管理员:110\n";
}
} catch (PDOException $e) {
echo 'Connection failed:' . $e->getMessage();
echo "\n";
}
//显示结果
$aaa = ($db->query("select * from record"));
$temp = $aaa->fetchAll(PDO::FETCH_ASSOC);
print_r($temp);
//借书时限为一个月
$borrowTime = date('Y-m-d');
$backTime = date("Y-m-d", (time() + 3600 * 24 * 30));
echo "借书成功,请于" . $backTime . "内归还!\n";
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/Leo4367/Library.git
[email protected]:Leo4367/Library.git
Leo4367
Library
Library
master

搜索帮助