Jump to content

Imkindadumb

New Members
  • Posts

    7
  • Joined

  • Last visited

Imkindadumb's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank youu the insert into query for the borrowedbooks table works fine now its just that the validation that i needed to do before it inserts into the borrowed table that was the problem.
  2. But that is my real code its shameful i knw but thats all I know for the moment. Started self learning on this just yesterday and the error word for word is this Parse error: syntax error, unexpected '$sql' (T_VARIABLE), expecting '(' on line 49
  3. when they give it back the admin will delete that record from the borrows table manually.
  4. The borrowedbooks table will only hold the customers ID book ID and the day it was borrowed, which is all the details that the user puts in. Its only just to act as a record of someone borrowing that book. I just need to check the number of books remaining in the quantity column in the all books table to be compared and decremented when someone borrows that book. meaning i probably have to write updatee queries for the all books table. call up the cell in the quantity colum that corresponds with the ID the user puts in, check if that number is above 1 and decrement it if is or return a sorry no books message. The error i get is to do with the sql part it just tells me that the variable $sql is not recognised sorry I didnt add that earlier. When you say if "something interrupts the process do you mean if someone tries to mess around and get passed the validation? If so im not really focusing on that because this is for an assignment and i am trying to do the bare minimum. Surprise deadlines always get you in a fix you knw. Im just looking for a structure to execute this. If you knw any websites that has this displayed? Does my code make any sense, its structure?
  5. 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";
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.