Note that there are some explanatory texts on larger screens.

plurals
  1. POmultiple countdown with mysql
    text
    copied!<p>I have a serious problem and I can't resolve. I need to put multiple countdown to work but in my code, just one countdown works fine. I can't understand why the others datetime can't be read. I'm using database to get datetime.</p> <p>Here my code:</p> <pre><code>$stmt4 = $mybd-&gt;prepare($query3); $stmt4-&gt;bind_param("s",$cat); $stmt4-&gt;execute(); $stmt4-&gt;bind_result($idVoucher,$titulo,$descricao, $precoOriginal, $desconto,$data, $nome, $nomeImagem); while($stmt4-&gt;fetch()){ if($cat == $nome){ if($idVoucher != $idVoucher2){ echo "&lt;input id='data2' type='hidden' value='$data' /&gt;"; </code></pre> <p>And i using this script to countdown:</p> <pre><code>$(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()) &gt; ts){ // The new year is here! Count towards something else. // Notice the *1000 at the end - time must be 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' ) + " and "; message += seconds + " second" + ( seconds==1 ? '':'s' ) + " &lt;br /&gt;"; } }); $('#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' ) + " and "; message += seconds + " second" + ( seconds==1 ? '':'s' ) + " &lt;br /&gt;"; } }); }); </code></pre> <p>How I can resolve this? keep my dateTimes into array and using into my script? For the case, how i did that?</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload