hello guys i need help I'm looking for a way to create a program that allows every minute incrementing a variable (eg "a") of +10. everytime that variable is incremented will be must save in the database the result I did something like this in javascript: <html> <body> <script type="text/javascript"> /*countdown - conto alla rovescia*/ var_anno=2020; var_mese=11; var_giorno=30; var_ore=16; var_minuti=0; var_secondi=0; a=0; function countdown() { data_scandeza= new Date(var_anno,var_mese-1,var_giorno,var_ore,var_minuti,var_secondi); data_oggi= new Date(); differenza=(data_scandeza-data_oggi); giorni=parseInt(differenza/86400000); differenza=differenza-(giorni*86400000); ore=parseInt(differenza/3600000); differenza=differenza-(ore*3600000); minuti=parseInt(differenza/60000); differenza=differenza-(minuti*60000); secondi=parseInt(differenza/1000); differenza=differenza-(secondi*1000); if (secondi < "1") { a=a+10; } if (giorni <= "0" && ore <= "0" && minuti <= "0" && secondi <= "0") { document.getElementById("countdown").innerHTML="Tempo scaduto"; } else { document.getElementById("countdown").innerHTML=secondi+' sec <br><br>' +a+ ' a'; setTimeout("countdown()",1000) } } </script> <body onload="countdown()"></body> </html> as you can see this is a countdown that increases every minute a variable. how can I do to bring the variable from javascript to php? you have any ideas on how to develop this idea?
You have to understand how a web server works. It loads the PHP file and sends it to the PHP parser. The parser generates the Javascript, HTML and CSS code and send it to the browser. At this point, PHP is no longer in the picture, and there are no more PHP variables. The browser executes the Javascript code. If you want Javascript to send the variable to the server, to put it into a database, use AJAX. (You'll have to read an AJAX tutorial and play with AJAX to learn how to use the technique, and various ways to do it. For instance, you can use jQuery to make it trivial, at the expense of a much heavier site.) I assume that you already know programming, PHP and SQL - if not, you'll have to learn them first.