Ok, first I am sorry for just dumping this here but I cannot think of what to search for to answer this one!
I have a shopping cart script that allows a user to select the color, size and quantity of a clothing item and put it in the shopping cart. When they hit submit it launches the form action to a script called addtocart.php which uses the code:
$buy = "INSERT INTO cart VALUES('$PHPSESSID', '$sku', '$qty', '$size', '$color')";
$buy_result = mysql_query($buy,$connect)
or die ("Couldn't insert record!");
to insert the selected item. Size, color and quantity are posted to this script and I used $color = $_POST['color']; to yank it back out, above the insert, works great!
But I do not want the user to be able to go back a few minutes later and add the same thing again and have it show up on a diferent row in the cart. How can I check for an item already existing, say by the variable sku, and if it there either popup an error or just add the new quantity to the existing one? I'm lost! Thanks for any help, this board has helped me a lot so far!
Oh, if way wanna see my workspace go to www.morphosnaturals.com/catalog.php and click view all under the Health section, then add something to the cart....