I have a Video Game programmed in HTML and JavaScript from which I wish to pass the points obtained to the MySQL Database and I can not find the correct way to achieve it.
JavaScript Code:
function updateScore(){
var score = (snakeLength - startLength) * 10;
document.getElementById('score').innerHTML = score;
}
function gameScore() {
$('#ribbon').addClass('hide');
var highScore = localStorage.getItem("high-score");
var score = (snakeLength - startLength) * 10;
$('.current-score').html(score);
if (score > highScore) {
$('#ribbon').removeClass('hide');
$('.high-score').html(score);
localStorage.setItem('high-score', score);
} else {
$('.high-score').html(highScore);}
gameMenu();
}
HTML code (shows the current points of the game):
Puntos: <span id="score">0< /span>
PHP Code:
I need to perform an update of points in my Database but I do not know how to pass the <span id="score">
tag to a PHP variable. For AJAX it would be ideal but it is more difficult for me.
// Necesito El Resultado en Point
mysql_query("UPDATE game SET point=$VARIABLE_PUNTOS ");