<?php
require_once 'tool/infos.php';
if($_POST){
//接收用户输入的信息
$serch = $_POST['serch'];
$sql = "select name, chu, author, price from books where name='{$serch}'";
$res=query($sql);
$books = [];
if($res -> num_rows > 0){
$books = $res -> fetch_all(MYSQLI_ASSOC);
}else{
echo "<script>alert('未搜索到该书本')</script>";
echo "<script>window.location.href='all.php'</script>";
}
}
?>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="shortcut icon" href="icon/logo.png" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="css/all.css">
<link rel="stylesheet" type="text/css" href="css/index.css">
<script src="js/jquery.js"></script>
<title>图书管理系统</title>
</head>
<body>
<div class="box">
<div class="menu" ondragstart="return false" onselectstart="return false">
<div class="menu_title">
当前管理员:<text><?php echo $name ?></text>
</div>
<div class="select" style="background: #3482ff;border-left: 0.4rem solid #aa00ff;font-weight: bold;">
<div class="select_icon">
<img src="icon/all.png">
</div>
<div class="name">预览全部</div>
</div>
<div class="select" onclick="addpage()">
<div class="select_icon">
<img src="icon/add.png">
</div>
<div class="name">添加书本</div>
</div>
<div class="select" onclick="alterpage()">
<div class="select_icon">
<img src="icon/alter.png">
</div>
<div class="name">修改书本</div>
</div>
<div class="select" onclick="deletepage()">
<div class="select_icon">
<img src="icon/delete.png">
</div>
<div class="name">删除书本</div>
</div>
</div>
<div class="content">
<form action="all.php" method="post">
<div class="search">
<input class="aa" type="text" name="serch" placeholder="输入准确的图书名进行查找">
<button type="submit">搜索</button>
</div>
</form>
<div class="books">
<div class="books_title">
<div>编号</div>
<div>书名</div>
<div>出版社</div>
<div>作者</div>
<div>售价</div>
</div>
<div class="book_list">
<?php for($i=0; $i<count($books); $i++){ ?>
<div class="book">
<div>
<?php if(count($books)<10){ ?>
<?php echo "2021000",$i + 1 ?>
<?php }else if(count($books)<100){ ?>
<?php echo "202100",$i + 1 ?>
<?php }else if(count($books)<1000){ ?>
<?php echo "20210",$i + 1 ?>
<?php }else if(count($books)<10000){ ?>
<?php echo "2021",$i + 1 ?>
<?php } ?>
</div>
<div><?php echo $books[$i]['name'] ?></div>
<div><?php echo $books[$i]['chu'] ?></div>
<div><?php echo $books[$i]['author'] ?></div>
<div>¥<?php echo $books[$i]['price'] ?></div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</body>
</html>
<script type="text/javascript">
// 获取菜单栏,图书列表元素
var select = document.getElementsByClassName("select")
var book_select = document.getElementsByClassName("book")
// 图书列表点击样式
for (var a = 0; a < book_select.length; a++) {
book_select[a].onclick = function() {
for (var j = 0; j < book_select.length; j++) {
if (book_select[j] == this) {
book_select[j].classList.add('bactive')
} else {
book_select[j].classList.remove('bactive')
}
}
}
}
// 菜单栏跳转
function addpage(){
window.location.href='add.php'
}
function alterpage(){
window.location.href='alter.php'
}
function deletepage(){
window.location.href='delete.php'
}
</script>
评论0
最新资源