I found the count down script in http://www.dynamicdrive.com/dynamicindex6/dhtmlcount.htm
It works fine if i just define the date but when I try to pass the date from this php/mysql query into the js file, it works only for the first record and not after that.
<script type="text/javascript" src ="time.js"></script>//this is the script from the above link. this directly gets todays date inside this code
<?php
$result = mysql_query("SELECT * FROM my_table LIMIT 10") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$id = $row['id'];
$title = $row['title'];
$date = date("F d, Y", strtotime($row['date']));
echo '<tr><td>';
echo $title;
echo "</td><td>";
echo $id;
echo "</td><td>";
echo $date; //display the date directly from the table as June 25, 2010
echo "</td><td>";
?>
<!-- this js code and the div is to show the countdown from today like 3D 2H 5M 45-->
<div id="container"></div>
<script type="text/javascript">
var futuredate=new cdtime("container", "<?php echo $date ;?>")
futuredate.displaycountdown("days", formatresults)
</script>
<?php
echo "</td></tr>";
}
}
?>
I tried wrapping the js code as php by using echo but it doesnt show anything(not even the output for first record). The above code clearly does what it has to do because I closed that php and opened the js so that's why its not looping. but I am guessing there should be away.
Please help me out.