Okay I must say this first I very new to php and this is my first time trying it out so please expect a dumb a question. I have 2 tables allbooks and borrowedbooks. All books has a column name quantity, so when someone borrows a book I want that quantity to go down by -1 and if the quantity is 0 to pass a message saying sorry no books or something like that. I went all over online but I cant even find a basic structure to do what i want to do. I still have to add the part where I instruct the system to -1 from the quantity table in all books, so far its just asking it to check the number but I get errors and the page doesnt even load. If anyone could point me to page that would give me a structure on how to do this or help me code it id be very grateful.
<tr>
<td> Enter User ID:</td>
<td> <input type="text" name="uid" size="48"> </td>
</tr>
<tr>
<td> Enter Book ID:</td>
<td> <input type="text" name="bid" size="48"> </td>
</tr>
<tr>
<td> Enter borrowed date:</td>
<td> <input type="date" name="bdate" size="48"> </td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="submit3" value="submit">
</td>
</tr>
</table>
</form>
</div>
<?php
include("dbcon.php");
if(isset($_POST["submit3"]))
{
if
$sql = mysqli_query("SELECT bid, bstatus FROM Allbooks WHERE bid = '$_POST[bid]';");
if (!$sql) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$row = mysql_fetch_row($result);
echo $row[0]; // 42
echo $row[1]; // the email value
if $row[0] > 0{
$uid = $_POST["uid"];
$bid = $_POST["bid"];
$bdate = $_POST["bdate"];
$query = "insert into Borrowedbooks(uid,bid,borroweddate) values('$uid','$bid','$bdate')"; //Insert query to add book details into the book_info table
$result = mysqli_query($conn,$query);
}
echo" Sorry there are no more copies";