I have a column in the database named time
, it has an event that does the following:
UPDATE users SET time = time - 1
As default you get 1800 seconds (30 minutes) right?
Now I wanted to recover the decaying time I tried the following:
<?php
$database = new DB;
/*Selectiono meu usuário*/
$select = $database->select($username);
/*Aqui retorno tudo*/
$fetch = $select->fetch(PDO::FETCH_ASSOC);
/*Aqui imprimo na tela o conteúdo do campo time*/
echo $fetch['time'];
?>
Now I tried to do the following to recover, but it does not appear. That is, it does not work.
$(document).ready(function() {
$('.contagem').css('display', 'block');
$('.contagem').html("<?php echo $fetch['time']?>");
});
From the error on the first line:
$(document).ready(function() {
I revamped this site and nothing helped me.
Edit
Code all
<?php
$database = new DB;
/*Selectiono meu usuário*/
$select = $database->select($username);
/*Aqui retorno tudo*/
$fetch = $select->fetch(PDO::FETCH_ASSOC);
/*Aqui imprimo na tela o conteúdo do campo time*/
echo $fetch['time'];
?>
<!DOCTYPE html>
<html>
<head>
<title>
Contagem
</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script></head><body><spanclass="contagem" style="display: none;"></span>
<script type="text/javascript">
$(document).ready(function() {
$('.contagem').css('display', 'block');
$('.contagem').html("<?php echo $fetch['time']?>");
});
</script>
</body>
</html>
Note: When you reach 0 reload the page.