I'm trying to extract information from one table to update another table with some of the information from the previous table and some input from the user. Everything is working like it should until I get to the this part of the code.
$amount is passed from another function
$sql="SELECT inventoryID,quantity FROM rel_command_inventory WHERE commandID=".$id;
$result=mysqli_query($conn,$sql);
while($data = mysqli_fetch_array($result))
{
$sql="UPDATE inventory SET quantity=quantity-".($amount*$data["quantity"])." WHERE id=".$data["inventoryID"];
$result=mysqli_query($conn,$sql);
........
........
}
mysqli_fetch_array($result) is returning this warning and is not executing the next part of the code:
mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given
I have already tried the code in phpMyAdmin SQL to be sure that I'm retrieving what I want and it works fine. But for some reason in PHP is not working... Please Help.