Button click counter save number

前端 未结 2 1574
花落未央
花落未央 2020-12-18 15:53

I have this fiddle where when the user clicks a button the counter works: http://jsfiddle.net/z66WF/

This is the code:

2条回答
  •  抹茶落季
    2020-12-18 16:42

    You need a DB connection to do this.

    When the button is clicked, by any user, the value from let's say: "downloaded_times" will be increased with 1.

    so you will need a query like:

    UPDATE table SET downloaded_times = downloaded_times + 1

    this query will be called each time someone presses the button.

    If you want to display it, before a certain user wants to start a download, you simply fetch the result from DB and the echo it. You can do more, if you want that field to be constantly refreshed, the fetching and echoing part should be in a ajax called PHP function, that will refresh the div (for instance) every 30 second or so :D

    Hope this helps! :D

提交回复
热议问题