Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript timer not looping along with mysql_fetch_array results
    text
    copied!<pre><code>&lt;? while($row = mysql_fetch_array($result)) { $result2 = $row['end_time']; echo"&lt;td&gt;&lt;div id=defaultCountdown&gt;&lt;/div&gt;&lt;/td&gt;"; ?&gt; &lt;script type=text/javascript&gt; $(function () { var t = ('&lt;? echo $result2; ?&gt;').split(/[- :]/); // Apply each element to the Date function var d = new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]); $('#defaultCountdown').countdown({until: d}); $('#year').text(austDay.getFullYear()); }); &lt;/script&gt; &lt;? } ?&gt; </code></pre> <p>So basically I wanted to launch the Javascript countdown timer for each row of results generated by mysql_fetch_array. However, in the code above, the timer only works for the first row of result. How do I make the timer work for every row of result?</p> <p>EDIT</p> <pre><code> &lt;td&gt; 2012-12-17 13:12:22&lt;/td&gt;&lt;td&gt; &lt;img src = Images/1324133424.jpg height=200 width=300 /&gt; &lt;/td&gt;&lt;td&gt; active&lt;/td&gt;&lt;td&gt;&lt;div id=defaultCountdown0&gt;&lt;/div&gt;&lt;/td&gt; &lt;script type=text/javascript&gt; $(function () { var t = ('2012-12-17 13:12:22').split(/[- :]/); // Apply each element to the Date function var d = new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]); $('#defaultCountdown0').countdown({until: d}); $('#year').text(austDay.getFullYear()); }); &lt;/script&gt; &lt;td&gt; 2012-12-01 13:12:22&lt;/td&gt;&lt;td&gt; &lt;img src = Images/1322754818.jpg height=200 width=300 /&gt; &lt;/td&gt;&lt;td&gt; active&lt;/td&gt; &lt;td&gt;&lt;div id=defaultCountdown1&gt;&lt;/div&gt;&lt;/td&gt; &lt;script type=text/javascript&gt; $(function () { var t = ('2012-12-01 13:12:22').split(/[- :]/); // Apply each element to the Date function var d = new Date(t[0], t[1]-1, t[2], t[3], t[4], t[5]); $('#defaultCountdown1').countdown({until: d}); $('#year').text(austDay.getFullYear()); }); &lt;/script&gt; </code></pre>
 

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