Jump to content

AnViLe

New Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by AnViLe

  1. FetchColumn() doesn't work on my end like it is an undefined method can I use fetch_assoc() as an alternative? I am using vscode so I think I missed out some files needed for php
  2. I got questions about your solution: 1.)What is prepare() function? Is it the same as mysqli_query() and is execute() also the same with mysqli_query()? 2.)"$available = intval($res->fetchColumn());" Does this code mean you're storing the data from the table to a variable $available and that specific data is the ID? 3.) Does the "?" represent the user's input?
  3. $delete = mysqli_query($connection,"SELECT Quantity FROM Books WHERE (ID='$idB' AND Quantity < 1)"); if($delete){ $delete_run = mysqli_query($connection,"DELETE FROM Books WHERE ID='$idB'"); echo "<script>alert('Book successfully deleted!')</script>"; }else{ $remove= mysqli_query($connection, "UPDATE Books SET Quantity = Quantity - $quantityB WHERE (ID='$idB' AND Quantity > 0)"); if($remove){ echo "<script>alert('Book successfully removed!')</script>"; } } } My goal here is to delete a data from a table only if the quantity reaches zero and I am having trouble on how to implement that idea what I have so far is just deleting the data with whatever ID was input by the user. $idB and $quantityB are the variables that I used to store user input. Need help
×
×
  • 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.