Jump to content

[SOLVED] Show picture based on the date


SteveEn_E

Recommended Posts

Hello,

 

been trying to figure out how I can add some php-code into my sidebar of wordpress so that it automatically shows a different picture based on the date.

 

I'm going to do a roadtrip and would like to show the map of what we are doing that day so I figured based on some guidelines from a friend I would try this:

 

<li>

 

<h2>Wat doen we vandaag?</h2>

 

<ul>

 

<?php

$vandaag = mktime(0,0,0,date("m"),date("d"),date("Y"));

$waar=(d-m-Y);

 

Switch ($waar)

 

case="04-08-2009":

<img src="http://temp.com/wp-content/6Aug.jpg" alt="Los Angeles">;

 

?>

 

</ul>

 

</li>

 

But it aint really showing something, actually the whole sidebar disappears when I add that little line of code...

 

Link to comment
https://forums.phpfreaks.com/topic/168777-solved-show-picture-based-on-the-date/
Share on other sites

Switch ($waar)

case="04-08-2009":
<img src="http://temp.com/wp-content/6Aug.jpg" alt="Los Angeles">;

 

Should be

 

Switch ($waar)
{
case="04-08-2009":
echo "<img src=\"http://temp.com/wp-content/6Aug.jpg\" alt=\"Los Angeles\">;
break;
}

 

However, this does not belong in the Regex forum

The syntax is completely wrong. Should be:

 

$waar = ("d-m-Y");

switch ($waar) {
    case "04-08-2009":
        echo '<img src="http://temp.com/wp-content/6Aug.jpg" alt="Los Angeles">';
        break;
    case "05-08-2009":
        // ...
        break;
}

Thxs for the help, sorry for the wrong section...

 

I'm currently testing this, and it is working with text but not with images (like I want to use them). Any idea what the reason could be?

 

Also, it seems to not be possible to show the image/text of the selected date. I added the default line and its always showing this. Might there something wrong in the mktime?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.