View Single Post
ישן 02-10-06, 22:12   # 3
RS324
תודה על תרומתך.
 
מיני פרופיל
תאריך הצטרפות: May 2006
הודעות: 3,173

RS324 לא מחובר  

עקרונית הדף נראה ככה :

PHP קוד:
<html>
<head>
<title>rs   test</title>
</head>

<script type="text/javascript">
 var dbtime = 1159809538; // the time user started the game
 var timenow = <?php echo time(); ?>; // the time now
 var endtime = 1159820338 // time the game supuse to be end
 
 function timeleft()
 {
     // will take endtime-dbtime
     var diff = (endtime-timenow);
    var days = Math.floor(diff/60/60/24);
    diff -= days*60*60*24;
    var hours = Math.floor(diff/60/60);
    diff -= hours*60*60;
    var mins =  Math.floor(diff/60); 
    diff -= mins*60;
    var seconds = diff
    //document.getElementById('clock').innerHTML =
    var text = days + ' Days ' + hours +' Hours ' + mins + ' Minutes '  + seconds + ' Seconds ';
    document.getElementById('clock').innerHTML = text;
         
     
 }

function runall()
{
//    timenow = timenow+1;
    timenow++;
     timeleft();
}
function init()
{
    
    setInterval("runall()",1000);
}
 

</script>

<body onload="init();">

<div> this is body</div>

<div id="clock">&nbsp;</div>
 
</body>
</html>
עכשיו מה שחשוב זה שלושת המשתנים הראשונים
ערכתי אותו קצת כשחיברתי אותו למערכת שלי

עכשיו הוא יוצר שעון שסופר אחורה
כי הוא מגדיל את TIMENOW ב 1 כל שניה
עכשיו כשאתה עושה ריענון או POST או לא משנה מה
אתה מקבל את ה TIME החדש שזה בעצם יוצא אותו דבר בדיוק.