PDA

View Full Version : Display Mulitple Instances of Time Remaining



penster1
03-06-2008, 10:18 PM
1) Script Title: Universal Countdown

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex6/universalcountdown.htm

3) Describe problem: How do i display multiple instances of Time Remaining. I currently have this script installed pulling a targetdate from a mysql database.

If there is only 1 item then it displays correctly. The information is displayed in a table with table headers of Item# Description Date End Time Remaining.
Sometimes there are only 10 items other times there may be 30 items or more. The field from my database thats stores all the end dates is called $targetdate. The page is designed in php. When using the following script it will only show in one row of the items, instead of all showing.

<script type="text/javascript">
var launchdate=new cdLocalTime("cdcontainer", "server-php", -60, "<?php echo $targetdate ?>", "debugmode")
launchdate.displaycountdown("days", noblank)
</script>

thetestingsite
03-06-2008, 10:30 PM
You could just do something like the following:



<?php
/*rest of code leading up to the query and while loop */
while ($q = mysql_fetch_array($query)) {
?>
<?php $q['item']; ?> Ending:<div id="cdcontainer"></div>

<script type="text/javascript">
//cdLocalTime("ID_of_DIV_container", "server_mode", LocaltimeoffsetMinutes, "target_date", "opt_debug_mode")
//cdLocalTime.displaycountdown("base_unit", formatfunction_reference)

//Note: "launchdate" should be an arbitrary but unique variable for each instance of a countdown on your page:

var launchdate=new cdLocalTime("cdcontainer", "server-php", 0, "<?php echo $targetdate;?>")
launchdate.displaycountdown("days", formatresults2)
</script>

<br>

<?php
}
?>


If that fails, then for each item, you will need to change the container id and the variable for the launchdate.



<script type="text/javascript">
var launchdate=new cdLocalTime("cdcontainer", "server-php", -60, "<?php echo $targetdate ?>", "debugmode")
launchdate.displaycountdown("days", noblank)
</script>


You could try changing the part in red (being that you are using php and mysql to display the items) to be your product name or some other field from the db. Same with the container, change it to be something else as well.

Hope this helps.

penster1
03-08-2008, 05:34 AM
After much thought, trial and error i was finally able to make multiple timers appear on my page. Thanks to everyone