Hi thanks for reading, got the following code, was working and not it is not. I want timers for each item, timer countdown being pulled from MySQL.
Thanks.
<script type="text/javascript">
<?php $selectTimers = mysql_query("SELECT * FROM auctions ORDER BY itemID DESC"); while($fetchTimers = mysql_fetch_array($selectTimers)) { $itemID = $fetchTimers['itemID']; $itemYears = $fetchTimers['itemYears']; $itemMonths = $fetchTimers['itemMonths']; $itemDays = $fetchTimers['itemDays']; $itemHours = $fetchTimers['itemHours']; $itemMinutes = $fetchTimers['itemMinutes']; $itemSeconds = $fetchTimers['itemSeconds']; ?>
itemTimeLeft<?=$itemID;?> = new Date(<?=$itemYears;?>,<?=$itemMonths - 1;?>,<?=$itemDays;?>,<?=$itemHours;?>,<?=$itemMinutes;?>,<?=$itemSeconds;?>);<?="\n";?>
<? } ?>
function GetCount(ddate,iid){
dateNow = new Date();
amount = ddate.getTime() - dateNow.getTime();
delete dateNow;
if(amount <= 0){
ended = document.getElementById(iid);
ended.innerHTML = "Auction Ended";
}else{
days=0;hours=0;mins=0;secs=0;out="";
amount = Math.floor(amount/1000);
days=Math.floor(amount/86400);//days
amount=amount%86400;
hours=Math.floor(amount/3600);//hours
amount=amount%3600;
mins=Math.floor(amount/60);//minutes
amount=amount%60;
secs=Math.floor(amount);//seconds
if(days != 0){out += days +" "+((days==1)?"day":"days")+", ";}
if(hours != 0){out += hours +" "+((hours==1)?"hour":"hours")+", <br />";}
out += mins +" "+((mins==1)?"min":"mins")+", ";
out += secs +" "+((secs==1)?"sec":"secs")+", ";
out = out.substr(0,out.length-2);
document.getElementById(iid).innerHTML=out;
setTimeout(function(){GetCount(ddate,iid)}, 1000);
}
}
function GetInfo(itemID) {
$('#bidAmount'+itemID).load('includes/auctions/getbid.php?itemID='+itemID);
$('#bidUsername'+itemID).load('includes/auctions/getbidder.php?itemID='+itemID);
<?php $selectTimers = mysql_query("SELECT * FROM auctions ORDER BY itemID DESC"); while($fetchTimers = mysql_fetch_array($selectTimers)) { $itemID = $fetchTimers['itemID']; ?>
setInterval(GetInfo("<?=$itemID;?>"), 1000);
<? } ?>
}
window.onload=function(){
<?php $selectTimers = mysql_query("SELECT * FROM auctions ORDER BY itemID DESC"); while($fetchTimers = mysql_fetch_array($selectTimers)) { $itemID = $fetchTimers['itemID']; ?>
GetCount('itemTimeLeft<?=$itemID;?>', 'itemTimer<?=$itemID;?>');<?="\n";?>
GetInfo("<?=$itemID;?>");<?="\n";?>
<? } ?>
};
</script>