954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

decrementing values in data base

Hi I want to know how i can decrement the value of quantity in stock in my data base. This would be based on how times an item is purchased.

So every time an item is clicked, i want to show the quantity has decreased in the database.

Pls help.

jody
Newbie Poster
3 posts since Aug 2005
Reputation Points: 10
Solved Threads: 0
 

Hi I want to know how i can decrement the value of quantity in stock in my data base. This would be based on how times an item is purchased.

So every time an item is clicked, i want to show the quantity has decreased in the database.

Pls help.


Well, when the hyperlink is clicked, whatever page the hyperlink goes to should contain something like this:

1. a connection string to your data base.

2. an SQL statement:

UPDATE [your table's name] SET [in-stock quantity fieldname] = ([in-stock quantity fieldname] - 1) WHERE [unique key fieldname] = [unique key value].

So... if your table was named "products" let's do an example:

UPDATE products SET InStockQty = (InStockQty - 1) WHERE productID = 3


get it?

Nicodemas
Newbie Poster
2 posts since Dec 2005
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You