PHP開(kāi)發(fā)簡(jiǎn)單圖書(shū)借閱系統(tǒng)完整還書(shū)功能實(shí)現(xiàn)程式碼
引入資料庫(kù)檔案config.php
<?php include("config.php");?>
建立完整的還書(shū)程式碼檔案huanshu.php
<?php require ('config.php'); //如果沒(méi)有登錄,退出 if ($_SESSION['id']==""){ echo "<script language=javascript>alert('您還沒(méi)有登陸');window.location='landing.php'</script>"; exit(); } $book_id=$_GET["book_id"]; //構(gòu)建sql語(yǔ)句還書(shū) //在lend表中刪除該借書(shū)記錄 $returnsql="DELETE FROM lend where book_id='$book_id' and user_id=".$_SESSION['id']; mysqli_query($link,$returnsql) or die ("刪除借書(shū)記錄失敗:".mysqli_errno($link)); //在book表中增加一本現(xiàn)存書(shū)數(shù)量 $booksql="UPDATE yx_books SET leave_number=leave_number+1 where id='$book_id'"; mysqli_query($link,$booksql) or die ("增加剩余書(shū)數(shù)量失?。?quot;.mysqli_error($link)); echo "<script language=javascript>alert('還書(shū)成功');window.location='index.php'</script>"; ?>