Hey guys,

I am trying to update the Quantity field in my database on button click. I have a checkout system, and on the final checkout page it displays my basket items in a listview bulleted list.

Now say there is 1 item, and the quantity is 5, upon the purchase button I want my stock table to be updated to have 5 less in the quantity field.

Cant seem to work out how to do this, as there are no labels or textboxes, just the listview so unsure how to word the SQL query.

What you have to do is to select that quantity field and subtract 5. When you will select the value, you then have to do an update over that field with the new value (Field = Field -5).

The way I have done it is that the data is stored in an SQL server database, so it would be like reading the data from the page. I dont want the listview to update, but the actual database.

If that makes sense lol. Checkout button -> checkout page containing listview with items added from basket which are stored in a temporary database -> update stocklevel to currentstocklevel minus(-)quantityordered.

Is this even possible?

To clarify a bit better hopefully, I have ultimately a page which can contain several different bits of data in list view form. For example, 3 bits of data each of which cntain ID, name, grind, quantity, price. When I click purchase, I want to update the stock databases' quantity to whatever it currently is for each item, minus the stock ordered.

e.g. pretend first one has 15 in stock and second has 30.
listview:

ID: 1
CoffeeName: Italian
Grind: Bean
Price: 10
Quantity: 5

ID: 3
CoffeeName: Directors
Grind: Espresso
Price: 5.50
Quantity: 10

[PurchaseButton] << update the stock database so set Italian and Directors to their new quantity in stock.
Not using sessions for this, thats why it is being passed through into a listview

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.