php - multiple countdown with mysql -
i have serious problem , can't resolve. need put multiple countdown work in code, 1 countdown works fine. can't understand why others datetime can't read. i'm using database datetime.
here code:
$stmt4 = $mybd->prepare($query3); $stmt4->bind_param("s",$cat); $stmt4->execute(); $stmt4->bind_result($idvoucher,$titulo,$descricao, $precooriginal, $desconto,$data, $nome, $nomeimagem); while($stmt4->fetch()){ if($cat == $nome){ if($idvoucher != $idvoucher2){ echo "<input id='data2' type='hidden' value='$data' />";
and using script countdown:
$(function(){ var data = $('#data').val(); var date_split = data.split(" "); var date = date_split[0]; date = date.split("-"); var time = date_split[1]; time = time.split(":"); var data1 = $('#data2').val(); var date_split1 = data1.split(" "); var date1 = date_split1[0]; date1 = date1.split("-"); var time1 = date_split1[1]; time1 = time1.split(":"); var note = $('#note'), ts = new date(date[0], date[1] - 01,date[2], time[0], time[1],time[2]), newyear = true; var note1 = $('#note1'), ts2 = new date(date1[0], date1[1] - 01,date1[2], time1[0], time1[1],time1[2]), newyear = true; /* if((new date()) > ts){ // new year here! count towards else. // notice *1000 @ end - time must in milliseconds ts = (new date()).gettime() + 10*24*60*60*1000; newyear = false; } */ $('#endtime_1320').countdown({ timestamp : ts, callback : function(days, hours, minutes, seconds){ var message = ""; message += days + " day" + ( days==1 ? '':'s' ) + ", "; message += hours + " hour" + ( hours==1 ? '':'s' ) + ", "; message += minutes + " minute" + ( minutes==1 ? '':'s' ) + " , "; message += seconds + " second" + ( seconds==1 ? '':'s' ) + " <br />"; } }); $('#endtime_1321').countdown({ timestamp : ts2, callback : function(days, hours, minutes, seconds){ var message = ""; message += days + " day" + ( days==1 ? '':'s' ) + ", "; message += hours + " hour" + ( hours==1 ? '':'s' ) + ", "; message += minutes + " minute" + ( minutes==1 ? '':'s' ) + " , "; message += seconds + " second" + ( seconds==1 ? '':'s' ) + " <br />"; } }); });
how can resolve this? keep datetimes array , using script? case, how did that?
thanks
i solved problem...there code if wants use. used keith-wood countdown , countdown works fine want question. when countdown finish, want update database.
how discover when countdown finish , next update database?
$query3 = "select v.id,v.titulo,v.descricao,v.precooriginal,v.desconto,v.datafinal,v.estado, c.nome,i.nome,i.tipo voucher v left join categoria c on v.id_categoria = c.id left join imagem on i.id_voucher = v.id c.nome = ? order v.id desc"; $stmt3 = $mybd->prepare($query3); $stmt3->bind_param("s",$cat);
$stmt3->execute(); $stmt3->bind_result($idvoucher,$titulo,$descricao, $precooriginal, $desconto,$data,$estado, $nome, $nomeimagem,$tipo);
while($stmt3->fetch()){ if($nome == $cat){ if($idvoucher == $idvoucher2 && $estado == "ativo" && $tipo == "paginaprincipal"){ ?> <h2><a href='./verofertacompra.php' ><?php echo $titulo ?></a></h2> <img class='imagem' src='./images/paginaprincipal/<?php echo $nomeimagem; ?>' /> <div class='info'> <div class='primeiro'> <input class='data<?php echo $idvoucher ?>' type='hidden' value=<?php echo $data; ?> /><br/> <span style="font-size: 15px; font-weight: bold; margin-left:38px;">este voucher termina em </span><br/><br/> <div id="defaultcountdown" class="endtime<?php echo $idvoucher ?>"></div> <script type="text/javascript"> $(function () { var = <?php echo $idvoucher ?>; var dataval = $(".data" + i.tostring()).val(); var data = new date(dataval); str = ".endtime"+i.tostring(); $(str).countdown({until: data, format: 'dhms'}); }); </script> <?php
Comments
Post a Comment