Count and show it on screen, but when reloading do not restart the count, either with JavaScript or Php


Hello friends, I would like to know how to make you tell me the number of click that you make to a part of a page, and show it, I would like to do it with php so that those clicks are saved in the database but it is easier with javascript but when reloading I reboot the count ..

Greetings and thank you in advance

asked by DanielDaniel 06.08.2018 в 19:38

2 answers


The most advisable thing is that you learn jquery whether you do not understand it or if it is basically something that is really necessary or almost obligatory, so to speak and the syntax is very easy. Look at this example.


    //hacemos una llamada ajax a un archivo php que guardara el click ejemplo





//por ejemplo esta sentecia sql actualisaria cada click que des 
$sql=mysqli_query($conn,"UPDATE guardar_click SET click=click+1");


 echo $row["click"];//retornamos el numero de veces que se ha clikeado

answered by 06.08.2018 / 20:08

if you use jQuery you can try the following


and in PHP you would only save +1 to a counter in some database

answered by 06.08.2018 в 19:45