Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Cabbit

macrumors 68020
Original poster
Jan 30, 2006
2,128
1
Scotland
PHP:
// Instert a frech product to the order
		$result = mysql_query("UPDATE `Order Items`  SET `Qty`=`Qty`+1 WHERE `ProductID` = '$productid'");
		if (mysql_affected_rows()==0) 
		{
			$result = mysql_query("INSERT INTO `Order Items` (`OrderNumber`,`ProductID`,`Qty`) VALUES 
				('$ordernumber','$productid','1')");
		}
This has been buging me till daylight, how do i get it to update if a record is already found with a compound key or ProductID and OrderNumber?
 
PHP:
// Instert a frech product to the order
		$result = mysql_query("UPDATE `Order Items`  SET `Qty`=`Qty`+1 WHERE `ProductID` = '$productid'");
		if (mysql_affected_rows()==0) 
		{
			$result = mysql_query("INSERT INTO `Order Items` (`OrderNumber`,`ProductID`,`Qty`) VALUES 
				('$ordernumber','$productid','1')");
		}
This has been buging me till daylight, how do i get it to update if a record is already found with a compound key or ProductID and OrderNumber?

Not fully sure I understand, but this might be what you're looking for: http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.