I have this query that will find a specific borrowDetail when i tried value 2 it does return data
from me but when i tried to find the 1 it does not give any data.
SELECT bd.BorrowDetails_ID, b.User_ID,
b.Accession_Code, bk.Book_Title, bd.Quantity, b.Date_Borrowed,
b.Due_Date, br.Borrower_ID, bd.tb_status
FROM
tbl_borrowdetails AS bd
INNER JOIN
tbl_borrow AS b ON bd.Borrower_ID = b.Borrow_ID
INNER JOIN
tbl_books AS bk ON b.Accession_Code = bk.Accession_Code
INNER JOIN
tbl_borrower AS br ON b.Borrower_ID = br.Borrower_ID
WHERE bd.BorrowDetails_ID = 21
then this is my query builder
on the borrower table it does have the data that i inserted on the other page, it registered and was distributed too on the other page, but when i call it in this return page, it does not work only the value 2 work,
i have tried to revise the query yet no success. it kept getting NO record found on the
// Check if the borrowId parameter is set in the URL
if(isset($_GET['borrowId'])) {
// Set the session variable after sanitizing it
$_SESSION['BorrowDetails_ID'] = filter_var($_GET['borrowId'], FILTER_SANITIZE_STRING);
// Optionally, you can redirect back to the same page or perform any other action
header("Location: staff_return_transaction.php");
exit();
}
// Initialize $bd_Id to an empty string
$bd_Id = $_SESSION['BorrowDetails_ID'];
// Prepare the SQL statement with a placeholder for the search input
$sql = "SELECT bd.BorrowDetails_ID, b.User_ID,
b.Accession_Code, bk.Book_Title, bd.Quantity, b.Date_Borrowed,
b.Due_Date, br.Borrower_ID, bd.tb_status
FROM
tbl_borrowdetails AS bd
INNER JOIN
tbl_borrow AS b ON bd.Borrower_ID = b.Borrow_ID
INNER JOIN
tbl_books AS bk ON b.Accession_Code = bk.Accession_Code
INNER JOIN
tbl_borrower AS br ON b.Borrower_ID = br.Borrower_ID
WHERE bd.BorrowDetails_ID = $bd_Id";
PLease do help me find what is wrong with my query as why it returns a value to me when i try 2 and why it does not return value when i ask for 1
2
Answers
i just changeg the target to borrow_ID from borrowDetails, i just found out that my where statement is the one that provides me with the wrong answer
should be