Update SQL field by 1 when clicking a button in php

I am currently making a website and was wondering how to make it so that when a button is clicked it will update a field in the database by +1. This is sort of a ‘download’ system for photos so someone can view a photo and then press download button to access it and this will add +1 to the ‘download’ field for that photo in the table same as for like fields.

Any help will be greatly appreciated.

thanks.

You can use a query like:-

UPDATE table SET dl-count = dl-count + 1 WHERE id = :id

Another approach I have used for recording downloads is new table for it. For every download I add a new row to the table. This let you record more info about the download, such as a timestamp or user info.

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.