1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Rep Power

    Can't Display Christmas Image

    Hi there,

    I am working on an advent calendar idea with 12 product deals. If we are on day one (which will be the 1st of December), I only want the first product deal to show. The remaining deals will be hidden by a christmas image. I have inherited some code that tries to solve this problem, however I can't seem to display the Christmas image for the remaining days? There is an else condition which is meant to display the christmas image if its not the right day. For some reason the else condition is not kicking in??

    I've not bothered so show all the CSS for the container divs etc but I think you get the idea that the products display in a box with a price, name, image rrp etc.

    Any help will be much appreciated.

    PHP Code:
    "9"=>array("image"=>"images/test9.jpg","link"=>"product9.html","name"=>"Test9","rrp"=>"&pound;39.99","salesprice"=>"&pound;25.00"),                                "10"=>array("image"=>"images/test10.jpg","link"=>"product10.html","name"=>"Test10","rrp"=>"&pound;19.99","salesprice"=>"&pound;10.00"),
    $d<=date("d")-6)echo "<a href=\"".$deal[$d]['link']."\"><div class=\"dealbox\"><h2>".($d).": ".$deal[$d]['name']."</h2><div class=\"container\"><img src=\"".$deal[$d]['image']."\"></div><div class=\"bottom\">RRP: ".$deal[$d]['rrp']."<br><span style=\"color:red;\"><b>Now: ".$deal[$d]['salesprice']."!</b></span></div></div></a>";
            else echo 
    "<div class=\"dealbox\"><h2>Opens in ".$next." day".($next==1?"":"s")."!</h2><div class=\"container\" style=\"height:150px;\"><img src=\"images/home/christmas-presents.jpg\" style=\"max-height:150px;\"></div></div>";
    Last edited by volterony; November 28th, 2012 at 07:55 AM.
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Pennsylvania, USA
    Rep Power
    1) Advent isn't 12 days (that's Saturnalia); Advent is 22-29 days depending on the year.

    2) This code displays a christmas image depending on the current day of the month minus six. It's not going to work for you today since it's the 28th, it will always display all the images.

    To test this, replace date("d") with a hard-coded value for the day you're trying to test, then adjust your math until it behaves the way you want.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2010
    Rep Power
    Thanks for your help there.

    Yes granted, Advent is a totally different thing

    Yes Maniac Dan, I've noodled about and passed in the 1st of December as the date minus 9, so the first product will appear on the 7th of December and they will run up until the 24th. Obviously this can be configured to run for whatever duration we specify.

    Thanks very much for your help.


IMN logo majestic logo threadwatch logo seochat tools logo