php循环中的jquery倒计时
我想使用KeithWoods倒计时jquery插件(http://keith-wood.name/countdown.html)在拍卖会上显示剩余的竞价时间,但我遇到了麻烦 当用户搜索时,php检索多个搜索结果,并将endtime的时间戳存储为varcharphp循环中的jquery倒计时,php,jquery,Php,Jquery,我想使用KeithWoods倒计时jquery插件(http://keith-wood.name/countdown.html)在拍卖会上显示剩余的竞价时间,但我遇到了麻烦 当用户搜索时,php检索多个搜索结果,并将endtime的时间戳存储为varchar while($row = $stmt->fetch(PDO::FETCH_ASSOC)){ $numrows++; $ID = $row['ID']; $img = $row['img'
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
$numrows++;
$ID = $row['ID'];
$img = $row['img'];
$desc = $row['description'];
$name = $row['name'];
$owner = $row['owner'];
$cprice = $row['cprice'];
$iprice = $row['iprice'];
$incprice = $row['incprice'];
$etime = $row['etime'];
$nextBid = $cprice + $incprice;
$stmt2 = $pdo->prepare("SELECT * FROM user WHERE username = :username");
$stmt2->bindParam(":username", $owner,PDO::PARAM_STR);
$stmt2->execute();
$thisuser = $stmt2->fetch(PDO::FETCH_ASSOC);
$location = $thisuser['location'];
echo'
<tr class="resultindex">
<td class="imgCol"><a href="displayAuct.php?id='.$ID.'"><img src="'.$img.'" alt="'.$name.'" /></a></td>
<td class="infoCol">
<div class="nameDiv">
<a class="nameLink" href="displayAuct.php?id='.$ID.'">'.$name.'</a><br/>
</div>
<div class="descDiv">
<span class="priceLabel2">'.$desc.'</span>
</div>
<div class="userdiv">
<span class="fromuser">Location: </span><br/>
<span class="location">'.$location.'</span>
</div>
</td>
<td style="width:1px; background-color:#330066;" ></td>
<td class="priceCol">
<div class="currentp"><span class="priceLabel">Current Bid: </span><br/><span class="price1">$'.$cprice.'</span></div>
<div class="instantp"><span class="priceLabel2">Instant Sale: </span><br/><span class="price2">$'.$iprice.'</span></div>
<div style="height:5px;"></div>
<div class="incp"><span class="priceLabel2">Next Bid:</span><br/><span class="price2">$'.$nextBid.'</span></div>
</td>
<td style="width:1px; background-color:#330066;"></td>
<td class="timerCol">
<div id="timeRow">
<span class="timeleft">Time Left: </span>
</div>
<div id="countdownRow"></div>
</td>
</tr>
';
}
while($row=$stmt->fetch(PDO::fetch_ASSOC)){
$numrows++;
$ID=$row['ID'];
$img=$row['img'];
$desc=$row['description'];
$name=$row['name'];
$owner=$row['owner'];
$cprice=$row['cprice'];
$iprice=$row['iprice'];
$incprice=$row['incprice'];
$etime=$row['etime'];
$nextBid=$cprice+$incprice;
$stmt2=$pdo->prepare(“从用户名=:用户名的用户中选择*);
$stmt2->bindParam(“:username”,$owner,PDO::PARAM_STR);
$stmt2->execute();
$thisuser=$stmt2->fetch(PDO::fetch_ASSOC);
$location=$thisuser['location'];
回声'
“.$desc.”
地点:
“.$location。”
当前出价:
$。$cprice
即时销售:
$。$iprice'
下一次出价:
$。$nextBid
剩余时间:
';
}
在代码的底部,我希望基于该特定项的倒计时计时器显示在countdownRow div中
我不知道如何用javascript处理这个问题,我想到了:
var timestamp = <?php echo $etime; ?> * 1000;
var endTime = new Date();
endTime.setTime(timestamp);
$(document).ready(function(e){
$(".cdtimer").load(function(){
$(".cdtimer").countdown({until: endTime});
});
});
var时间戳=*1000;
var endTime=新日期();
设置时间(时间戳);
$(文档).ready(函数(e){
$(“.cdtimer”).load(函数(){
$(“.cdtimer”)。倒计时({until:endTime});
});
});
但这似乎不起作用。有人知道我需要在这里做什么吗?第一句话:html中的id属性必须是唯一的。所以每一行都需要一个唯一的id 将每一行的
$etime
添加到一个单独的div中,以使html中的所有结束时间都可用
使用jquery查找所有timerCol
列,并为每个结果启动一个新计时器
$(".timerCol .timeLeft").each(function() {
endtime = $(this).find(".timeRowValue").val();
$(this).countdown({until: endTime});
};