im trying to create a simple SQL INSERT otherwise UPDATE statement but to be honest I don't know what im doing
here is my function so far
function addInventoryBook($isbn, $sku, $price, $quantity, $condition, $dateOpened){
$q = "INSERT INTO ".TBL_INVENTORY." VALUES('$isbn', '$sku', $price,
$quantity, '$condition', $dateOpened)
ON DUPLICATE KEY UPDATE VALUES('$isbn', '$sku', $price, $quantity,
'$condition', $dateOpened)";
return mysql_query($q, $this->connection);
}
a previous function which seemed that update the price field was working
function addInventoryBook($isbn, $sku, $price, $quantity, $condition, $dateOpened){
$q = "INSERT INTO ".TBL_INVENTORY." VALUES('$isbn', '$sku', $price,
$quantity, '$condition', $dateOpened)
ON DUPLICATE KEY UPDATE price = $price";
return mysql_query($q, $this->connection);
}
ON DUPLICATE KEY UPDATE SET price = VALUES(price), sku = VALUES(sku) ,quantity = VALUES(quantity), ....., you might need to add the field names between ".TBL_INVENTORY." and VALUES.echoyour query before you run it, make sure it's actually what you think it is.