I have an SQL database of one-off unique information items to sell.

I need a PHP script to ensure that they're only able to be bought once, and suspended from available inventory once put into a shopping cart... but put back into "for sale inventory" if the checkout is not successful, or the user just closes the browser/logs out.

This is not a tangible product, but unique information that can only be sold once.

Thanks!
Ray