Guest User

Untitled

a guest
Nov 23rd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <?php
  2. $conn = mysql_connect("localhost","root","");
  3. $sel = mysql_select_db("testing",$conn);
  4. $query=mysql_query("select * from table1");
  5. $res = mysql_fetch_array($query);
  6. do
  7. {
  8. $id = $res['id'];
  9. $name = $res['name'];
  10. $email = $res['email'];
  11. echo $date = $res['date'];
  12.  
  13. ?>
  14.  
  15. <script type="text/javascript">
  16.  
  17. var countDownDate = new Date("<?php echo $date; ?>");
  18.  
  19.  
  20. var x = setInterval(function() {
  21.  
  22. // Get todays date and time
  23. var now = new Date().getTime();
  24.  
  25. // Find the distance between now an the count down date
  26. var distance = countDownDate - now;
  27.  
  28. // Time calculations for days, hours, minutes and seconds
  29. var days = Math.floor(distance / (1000 * 60 * 60 * 24));
  30. var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  31. var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  32. var seconds = Math.floor((distance % (1000 * 60)) / 1000);
  33.  
  34. // Output the result in an element with id="demo"
  35.  
  36. document.getElementById("<?php echo $id; ?>").innerHTML = days + "days " + hours + "h "
  37. + minutes + "m " + seconds + "s ";
  38.  
  39. // If the count down is over, write some text
  40. if (distance < 0) {
  41. clearInterval(x);
  42. document.getElementById("<?php echo $id;?>").innerHTML = "EXPIRED";
  43. }
  44.  
  45. }, 1000);
  46. </script>
  47.  
  48.  
  49. <p style="color:red;">Remaining Time:
  50. <h1>
  51. <span id="<?php echo $id; ?>">
  52. We had to show here the Expity date for id no. <?php echo $id; ?></span>
  53. </h1>
  54. </p>
  55.  
  56.  
  57. <?php
  58. } while($res = mysql_fetch_array($query));
  59.  
  60.  
  61. ?>
Add Comment
Please, Sign In to add comment