For some reason my SQL UPDATE statement is not working.
$con=mysqli_connect("localhost","admin","password","db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$items = array();
$desc = array();
$price = array();
$quantity = array();
$p=0;
while($inventorynumber>$p)
{
$invid[$p] = $_POST['invid'.$p.''];
$items[$p] = $_POST['item'.$p.''];
$desc[$p] = $_POST['desc'.$p.''];
$price[$p] = $_POST['price'.$p.''];
$quantity[$p] = $_POST['quantity'.$p.''];
$sql = "UPDATE `inventory_db` SET `item`='$items[$p]',`description`='$desc[$p]',`quantity`='$quantity[$p]',`price`='$price[$p]' WHERE `invid` = '$invid[$p]'";
$p++;
}
Is there a more efficient way of doing this? Or do I need to add in a mysqli_close($con); after?