国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

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('編號(hào)不正確');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
// 借書(shū)
// 查看用戶ID是否已填
if ($_SESSION['id']==""){
   echo "<script language=javascript>alert('您還沒(méi)有登陸');window.location='landing.php'</script>";
   exit();
}else{
   // 可以正常借書(shū),記錄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ū)記錄中庫(kù)存剩余數(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 // 可以正常借書(shū),記錄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ū)記錄中庫(kù)存剩余數(shù)減一 mysqli_query($link,"update yx_books set leave_number=leave_number-1 where id='$book_id'"); ?>
submitReset Code