To get started on this you will need to ensure that you have a user login area of the site, there will be no way to securely deliver the items to the user unless you can verify their identity.
After you have that setup you will need to ensure that your items table has the file name listed there.
You will need to make sure that you are getting the order and details stored in your db at the time of the checkout.
One the checkout success page you can put in links to the files that the user has access to, they should go to your download page with an identifier attached to them to indicate the item id. On the download page you will create a recordset that selects all from the item details table and joins the items table on the item id, you will filter it by the item id and where the downloads left is >= 1 and where the userID matches the id of the logged in user.
For the download server behavior you will trigger it on the recordset if there is at least one result. For the file itself you want to make sure to reference the file name column from your items table. This way it will ensure that the user can only download items they have purchased and that there are downloads left for them on that item. If any of these conditions are not met then the download will not occur.
You will need to ensure that you have all of these parts in place, when you get to the query on the download page if you need any further assistance or direction let me know. The way I described it here should work but if it does not or if you have trouble following I will try to help you get it working.