Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $conn = mysql_connect("localhost","root","");
- $sel = mysql_select_db("testing",$conn);
- $query=mysql_query("select * from table1");
- $res = mysql_fetch_array($query);
- do
- {
- $id = $res['id'];
- $name = $res['name'];
- $email = $res['email'];
- echo $date = $res['date'];
- ?>
- <script type="text/javascript">
- var countDownDate = new Date("<?php echo $date; ?>");
- var x = setInterval(function() {
- // Get todays date and time
- var now = new Date().getTime();
- // Find the distance between now an the count down date
- var distance = countDownDate - now;
- // Time calculations for days, hours, minutes and seconds
- var days = Math.floor(distance / (1000 * 60 * 60 * 24));
- var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
- var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
- var seconds = Math.floor((distance % (1000 * 60)) / 1000);
- // Output the result in an element with id="demo"
- document.getElementById("<?php echo $id; ?>").innerHTML = days + "days " + hours + "h "
- + minutes + "m " + seconds + "s ";
- // If the count down is over, write some text
- if (distance < 0) {
- clearInterval(x);
- document.getElementById("<?php echo $id;?>").innerHTML = "EXPIRED";
- }
- }, 1000);
- </script>
- <p style="color:red;">Remaining Time:
- <h1>
- <span id="<?php echo $id; ?>">
- We had to show here the Expity date for id no. <?php echo $id; ?></span>
- </h1>
- </p>
- <?php
- } while($res = mysql_fetch_array($query));
- ?>
Add Comment
Please, Sign In to add comment