try

if (daysRound=<0) {

bastien


From: JeRRy <[EMAIL PROTECTED]>
To: php-db@lists.php.net
Subject: [PHP-DB] Xmas countdown code help!  (includes displaying images)
Date: Thu, 22 Dec 2005 19:26:47 +1100 (EST)

Hi,

I have created a little Christmas countdown on the site using PHP and mySQL. The database controls the images displayed. But to make it simplier as I know the problem does not reflect my db setup or talking to the db I've re-wrote the code into a JavaScript code. So it's easier to read.

The problem is the days to Christmas and images displayed display absolutely fine. But when there is 0 days to Christmas the NEW YEAR image does not display. :( But the countdown ones do.

  Here is the code:  *I have commented areas with //*

  <script type="text/javascript">
<!--
 function placeimg() {

  var currentDate = new Date();

  // December is month 11

  var endDate = new Date(2005, 11, 25, 23, 59, 59);

  var days = (endDate-currentDate)/1000/60/60/24;
  var daysRound = Math.floor(days);

  // Check when to put Sleeps and when to put sleep

  if (daysRound == 1) {
      var sleeps = "Sleep";
  } else {
      var sleeps = "Sleeps";
  }

  if (daysRound<=0) {
 var alttag = "Merry Christmas!"
document.write("<a target=\"_top\" href=\"/\"?PHPSESSID=c8b567b9f7640ce57720265db80b4f16gqkchtfzjqddmqgbzkepmohogd081925><img border=\"0\" src=\"/christmas05/"+daysRound+"_days.gif\" alt=\""+alttag+"\" height=\"/50\" width=\"/125\"></a>");


  } else {

      var alttag = ""+daysRound+" "+sleeps+" until Christmas"
document.write("<a target=\"_top\" href=\"/\"?PHPSESSID=c8b567b9f7640ce57720265db80b4f16gqkchtfzjqddmqgbzkepmohogd081925><img border=\"0\" src=\"/christmas05/"+daysRound+"_days"+".gif\" alt=\""+alttag+"\" height=\"50\" width=\"125\"></a>");
  }


 }
placeimg();
//-->
</script>

  You can see the code working at http://www.getpaid2reademails.com/

  Ignore the PHPSESSID.

Also it currently only records time left from your personal clock on your PC. How would I go about getting the server time instead?

But of course this would not be ideal for everyone in different countries but I wondered an easy way to do it.

  Thanks for your time.

  Jerry

Send instant messages to your online friends http://au.messenger.yahoo.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to