PHP develops the home page borrowing function of a simple book borrowing system

As shown in the picture

3.png

There is an operation directory under the operation bar on the main page that displays "I want to borrow books"

After clicking it, you can Start implementing the book borrowing function. If the current quantity is displayed as 0,

This column will be "The book has been borrowed". You cannot click to select this item.

1617.png

First determine whether the book number id has been filled in. If not, the user will be prompted

alert('编号不正确');window.location='index.php'"; exit(); } ?>

to check whether the user is logged in. If not logged in, the book cannot be borrowed

Record the current date after the user logs in to borrow a book

After a book is borrowed, the inventory of this book needs to be reduced by one

alert('您还没有登陆');window.location='landing.php'"; exit(); }else{ // 可以正常借书,记录id // 获得当前日期 $now = date("Y-m-d,H-i-m"); $lendsql="INSERT INTO lend(book_id, book_title, lend_time, user_id) values('$book_id','$title','$now','".$_SESSION['id']."')"; mysqli_query($link,$lendsql); // 借出后需要在该书记录中库存剩余数减一 mysqli_query($link,"update yx_books set leave_number=leave_number-1 where id='$book_id'"); echo ""; } ?>


Continuing Learning
||
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!