I don't know of any tutorials on this specific topic.
You could probably name your quantity field including the productID from the database like:
name="Quantity_Of_<?php echo($row['id']); ?>"
Then when submit it pressed, insert from the unfiltered recordset getting the quantity from the associated form field referenced by productID. Make sure blank ones are set to 0 and they should be skipped in the cart as well.