亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

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

<?php
$book_id = $_GET['book_id'];
if ($book_id==""){
   echo "<script language=javascript>alert('編號不正確');window.location='index.php'</script>";
   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

<?php
// 借書
// 查看用戶ID是否已填
if ($_SESSION['id']==""){
   echo "<script language=javascript>alert('您還沒有登陸');window.location='landing.php'</script>";
   exit();
}else{
   // 可以正常借書,記錄id
   // 獲得當(dāng)前日期
   $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);

   // 借出后需要在該書記錄中庫存剩余數(shù)減一
   mysqli_query($link,"update yx_books set leave_number=leave_number-1 where id='$book_id'");
   echo "<script language=javascript>alert('借閱完成');window.location='index.php'</script>";
  }
?>


Continuing Learning
||
<?php // 可以正常借書,記錄id // 獲得當(dāng)前日期 $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); // 借出后需要在該書記錄中庫存剩余數(shù)減一 mysqli_query($link,"update yx_books set leave_number=leave_number-1 where id='$book_id'"); ?>
submitReset Code