저는 데이터베이스에서 여러 경매 레코드를 가져 오는 데 사용하는 PHP 루프가 있습니다. 경매의 일부로서 나는 그것이 끝날 때까지 카운트 다운을 원한다. 나는 처음에는 단지 첫 번째 레코드가 카운트 다운 타이머 (작동 중)를 표시하고 그것이 jquery 선택기에 매번 같은 id를 부여했기 때문에 문제가 있음을 확인했습니다. 그래서 새로운 ID가 각 루프의 div 및 jquery 함수에 제공되도록 생성되었습니다. 하지만 지금은 내 스크립트의 결과를 보면 카운트 다운 타이머가 모든 테이블 행에 표시되지 않습니다.여러 jquery 카운트 다운 타이머가 PHP 루프 내에 표시되지 않습니다.
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
$ID = $row['ID'];
$cdRand = '#row'.$ID;
$img = $row['img'];
$desc = $row['description'];
$name = $row['name'];
$owner = $row['owner'];
$cprice = $row['sprice'];
$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();
$thisuser2 = $stmt2->fetch(PDO::FETCH_ASSOC);
$location = $thisuser2['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="timerCol">
<div class="currentp" style="height: 50px;"><span class="priceLabel">Current Bid: </span><br/><span class="price1">$'.$cprice.'</span></div>
<div id="timeRow" style="height: 30px;">
<span class="timeleft">Time Left: </span>
</div>
<div id="'.$cdRand.'" style="height:80px;"></div>
<script type=text/javascript>
var timestamp = '. $etime * 1000 .';
var endTime = new Date();
endTime.setTime(timestamp);
$("'.$cdRand.'").countdown({until: endTime});
</script>
</td>
</tr>
';
내가 확실히 작동하지 않는 이유를 말해, 카운트 다운 타이머가 키스 숲 카운트 다운 플러그인 http://keith-wood.name/countdown.html입니다 기운 다, 어떤 도움을 크게 감상 할 수있다.
환호 이것이 ID 선택기이다
병 $()로 그 jQuery를 변경 시도를 카운트 다운() 첫 어쩌면 – Bundy