cum asi putea sa fac, cand accesez pagina sa nu mai trebuiasca sa dau refresh pentru a porni timpu(vreau sa apara direct fara refreshuri).
Daca se poate dupa ce se termina timpu si primesc punctele sa reinceapa iar.
intru pe pagina respectiva si imi apare "munca se va relua dupa urmatoru refresh"
ii dau refresh pentru a porni cronometru pana primesc punctele, dupa terminare trebuia sa ii dau iar de 2 ori refresh pentru a reincepe punctarea
Cod: Selectaţi tot
case 7:
//recompensa
$usery = $_GET['user'];
$aur = 5; // punctele primite
$god = mysql_query("UPDATE users SET puncte = puncte + '".$aur."' WHERE user_name = '".$usery."'");
if($god){
echo '1';
} else {
echo '0';
}
break;
case 8:
//recompensa
$usery = $_GET['user'];
$started = time()+30; //60 = 1 min
$god = mysql_query("UPDATE users SET work_pct = '".$started."' WHERE user_name = '".$usery."'");
if($god){
echo '1';
} else {
echo '0';
}
break;
Cod: Selectaţi tot
<?php
// include 'database.php';
$flp = mysql_query("SELECT * FROM users WHERE user_name = '".$usernames."'");
$player = mysql_fetch_array($flp);
$pct = $player['puncte'];
$f = $player['work_pct'];
if(($f > 0) && ($f < time()) && ($f != 0)){
?>
<script type="text/javascript">
$(document).ready(function(){
var userl = $('#username_k').text();
$.ajax({
type:'POST',
url:'add_file.php?cod=8&user='+userl,
Async:false,
cache:false,
success:function(datau){
if(datau == 1){
alert('munca se va relua dupa urmatoru refresh');
}
}
});
});
</script>
<?php
} else
if($f > 0){
$dog = $f - time();
$done_work = date('H:i:s',$dog);
?>
<script type="text/javascript">
function work(ile){
var ora = Math.floor(ile/3600);
var minute = Math.floor((ile-ora*3600)/60);
var secunde = ile-minute*60-ora*3600;
if(ora<10){ ora = '0'+ora; }
if(minute<10){ minute = '0'+minute; }
if(secunde<10){ secunde = '0'+secunde; }
if(ile > 0){
ile--;
document.getElementById("ceasp").innerHTML = ora+':'+minute+':'+secunde;
setTimeout("work("+ile+")", 1000);
} else {
//alert('terminat');
$(document).ready(function(){
var userl = $('#username_k').text();
$.ajax({
type:'POST',
url:'add_file.php?cod=7&user='+userl,
Async:false,
cache:false,
success:function(data){
if(data == 1){
alert('ai primit recompensa');
}
}
});
});
}
}
</script>
<li class="header">(<?php echo $pct; ?>)<strong>Puncte - Timp: <span id="ceasp"></span></strong></li>
<script type="text/javascript">window.onload = work("<?php print $dog; ?>");</script>
<?php
} else {
?>
<script type="text/javascript">
$(document).ready(function(){
var userl = $('#username_k').text();
$.ajax({
type:'POST',
url:'add_file.php?cod=8&user='+userl,
Async:false,
cache:false,
success:function(datau){
if(datau == 1){
alert('cont nou - munca se va relua dupa urmatoru refresh');
}
}
});
});
</script>
<li class="header">(<?php echo 'null'; ?>)<strong>Puncte - Timp: <span id="ceasp">null</span></strong></li>
<script type="text/javascript">window.onload = work("<?php print $dog; ?>");</script>
<?php
}
?>