Forum Moderators: coopster

Message Too Old, No Replies

Specific Image for Specific Day

         

pHJason

6:47 pm on Oct 7, 2010 (gmt 0)

10+ Year Member



Hello.

I am looking to see if there is already created code for this function. Basically, I run a theater and would like a Now Playing section that shows the appropriate show image on the appropriate day. So Monday's show images only show up on Mondays, Tuesdays on Tuesdays, etc.

Does this already exist somewhere, or is there a tutorial?

Thanks in advance!

Jason

Anyango

7:07 pm on Oct 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Its going to be very easy to setup, are there few images per day or alot of ? is it like just displaying some images or its a slideshow?

pHJason

7:18 pm on Oct 7, 2010 (gmt 0)

10+ Year Member



Basically it will probably have to be one flash module per day. Check out annoyanceproductions.com and see how they do their intro flash slide there. They have today's shows only but you can toggle back and forth between them.

Make sense?

Matthew1980

7:54 pm on Oct 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

Sounds like a case for either an if/elseif/else chain or switch statement to me, just depends of what you prefer I guess, and how you want to split your day up, from that you can just load different files depending on what side of the clause you sit.

Have an experiment first, then when you get stuck or can't work out the logic, post it here, and we can suggest improvements or just be a fresh pair of eye's ;-p

Cheers,
MRb

rocknbil

4:13 pm on Oct 8, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would probably set a standard convention for file/variable naming so as new ones spring to life, you don't have to modify your programming, just upload and add to the database via whatever admin interface you have. Think about weather icons, it's the same scenario. You start with three.

select weather_description from table;

so this may return

sunny
rainy
stormy

and your weather directory should have
sunny.gif
rainy.gif
stormy.gif

So you'd do

$img = "/icondirectory/" . $row['weather_description'] . '.gif';
if (! is_file($_SERVER['DOCUMENT_ROOT'] . $img)) {
die("Oops. Maybe you forgot to upload it.");
}

echo "<img src=\"$img" alt=\"" . $row['weather_description'] . " today\">";

So then you'd just set up your admin to manage upload, extract the name from the file,

list($name,$ext) = explode('.',$filename);

insert into table (weather_description) values('$name');

Completely self-maintaining.

Following the logic through for days, you probably wouldn't even need to store the days but could still use mysql date format functions to get at the correct day.

monday.gif
tuesday.gif (etc.)

select dayname(curdate); // store in "$today"

$file = "/icondirectory/" . strtolower($today) . '.gif';