In this tutorial, we are going to learn how to create
Borrowing and Returning Function in PHP/MySQL. We all know, Library System have this two functions. You can use this source code to create a simple Library System or in any system that has to borrow and returning functions. Hope you can learn from this tutorial. Enjoy coding.
Account information
- Username: admin
- Password: admin
Here’s the to-do list
- Borrowed Items
- Returned Items
Sample Source Code
This sample PHP query is for the borrowing function.
<?php
require ('include/database.php');
require ('session.php');
$id = $_POST['selector'];
$client_id = $_POST['client_id'];
if ($id == '')
{
header("location: release.php");
?>
<?php
}
else
{
$release_id = $row['release_id'];
$history_record = mysql_query("select * from user where user_id=$id_session");
$user = $row1['firstname'] . " " . $row1['lastname'];
for ($i = 0; $i < $N; $i++)
{
mysql_query("INSERT INTO transaction_history (item_id,action,client_id,release_id,admin_name,date_added) VALUES ('$id[$i]','Borrowing Item','$client_id','$release_id','$user',NOW())") or
die(mysql_error());
mysql_query("insert into release_details (item_id,release_id,release_status) values ('$id[$i]','$release_id','pending')") or
die(mysql_error());
}
header("location: release.php");
}
?>
Related Code:
How to Make Library System
Library Management System with Barcode
If you have a question for this tutorial, don't to hesitate to ask, kindly leave your comment below. Thank you.