javascript is not looping with mysql_fetch_array result even though it showing timer on one product only .i don't know what mistake i have did ,,plz help me ,,i ma very new with php and java script..even i have taken javascript timer from google itself ..plz help me
<?php $conn = mysql_connect('localhost','root',''); if(!$conn) die("Failed to connect to database!"); $status = mysql_select_db('bidding', $conn); if(!$status) die("Failed to select database!"); $result = mysql_query("SELECT * FROM bids where id"); $numrow = mysql_num_rows($result); if ($numrow == 0) { die('No record found.'); } ?> <?php while($row=mysql_fetch_array($result)){ $closedate = date_format(date_create($row['closing_date']), 'm/d/Y H:i:s'); $images_field= $row['image']; $image_show= "images/$images_field"; ?> <div class="bidbar1"> <div id="lastsold"><strong>Last Sold : ₹ </strong><?php echo $row['lastsold']; ?> </div> <div id="title"><?php echo $row['description']; ?></div> <div id="detail"><img src="image/moredetail.jpg" height="150" alt="more detail" /> </div> <div id="image"><img src="<?php echo $image_show; ?>" width="205" height="150" alt="more detail" /></div> <div id="clock"><table><tr><td style="font-size:18px;text-align:center; padding- left:30px;">Days Hr Min Sec</td></tr> <tr><td style="font-size:32px; font:bold; text-align:center;padding-left:30px;"> <script>
var cdtd = function(id,end) {
var start = new Date();
var timeDiff = end.getTime() - start.getTime();
if(timeDiff <=0 )
{
//$('#bidbar1').remove();
//return;
// alert('We have lift off!');
//$('#bidbar1').delay(50000000).fadeout();
$(window).load(function(){$('#bidbar1').remove(); });
return false;
}
var seconds = Math.floor(timeDiff / 1000);
var minutes = Math.floor(seconds / 60);
var hours = Math.floor(minutes / 60);
var days = Math.floor(hours / 24);
hours %= 24;
minutes %= 60;
seconds %= 60;
$( id + " .days").html(days);
$( id + " .hours").html(hours);
$( id + " .minutes").html( minutes);
$( id + " .seconds").html( seconds );
console.log(id + " .hoursBox",$( id + " .hoursBox").length,id,end,hours,minutes,seconds)
var timer = setTimeout(function(){cdtd(id,end)},1000);
}
cdtd("#counter1",new Date("<?php echo $closedate; ?>"));
//cdtd("#counter2",new Date("march 16, 2014 18:06:30"));
//cdtd("#counter3",new Date("march 16, 2014 17:37:00"));
//cdtd("#counter4",new Date("march 16, 2014 17:38:00"));
//cdtd("#counter5",new Date("june 2, 2014 10:55:00"));
//cdtd("#counter6",new Date("April 2, 2014 10:30:00"));
//cdtd("#counter7",new Date("April 3, 2014 00:01:00"));
//cdtd("#counter8",new Date("April 1, 2014 00:01:00"));
//cdtd("#counter9",new Date("April 4, 2014 00:01:00"));
//cdtd("#counter10",new Date("April 5, 2014 00:01:00"));
//cdtd("#counter11",new Date("April 19, 2014 00:01:00"));
//cdtd("#counter12",new Date("April 20, 2014 00:01:00"));
</script>
<div id="counter1">
<div class="box days">0</div>
<div class="box hours">0</div>
<div class="box minutes">0</div>
<div class="box seconds">0</div>
</div>
</td></tr></table></div> <div id="mrp"><strong>MRP : ₹</strong><?php echo $row['mrp']; ?></div> <div id="endt"><strong>End Time: ₹</strong><?php echo $row['closing_date']; ?></div> <div id="fee"><strong>Bid Fee : ₹</strong><?php echo $row['bid fee']; ?></div> <div id="current"><strong>Current Winner</br>↓ </strong></div> <div id="buy"> <table width="271" border="0" cellpadding="0.1"> <tr> <td><img src="image/buy.png" alt="buy now" longdesc="http://buy now" /></td> <td width=110><?php echo $row['currentwinner']; ?></td> <td><img src="image/bid.png" alt="bid now" longdesc="http://bidnow " /></td> </tr> </table> </div></div> <?php } ?>