non-random image rotation in php

  • pony
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Feb 27, 2004
  • Posts: 7
  • Status: Offline

Post April 23rd, 2004, 2:15 pm

Does anybody know the php code for non-random image rotation?
I would like to have an image and its text change in my website every day automatically. What code can I use?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post April 23rd, 2004, 2:15 pm

  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Mar 24, 2004
  • Posts: 1855
  • Loc: Uk
  • Status: Offline

Post April 24th, 2004, 9:22 am

like a different text for each day of the week?
CSS website design tutorials
  • pony
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Feb 27, 2004
  • Posts: 7
  • Status: Offline

Post April 24th, 2004, 11:04 am

yes. exactly. different text and different image for each day of the week
  • Yellow19
  • Born
  • Born
  • No Avatar
  • Joined: Apr 21, 2004
  • Posts: 4
  • Status: Offline

Post April 24th, 2004, 4:05 pm

do it like this

if day == mo
img = blabla.gig
text = bleghblegh
else if day == tue
img = blabla.gig
text = bleghblegh
  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Joined: Feb 17, 2004
  • Posts: 279
  • Loc: Buenos Aires, Argentina
  • Status: Offline

Post April 24th, 2004, 4:17 pm

Naaahh...

Use the day of the year (number 1..365) and the % (modulus operator) with the total of images/text.

num = day % max_num
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Joined: Mar 20, 2004
  • Posts: 401
  • Loc: Scorpion Hole
  • Status: Offline

Post April 24th, 2004, 8:32 pm

Another solution for you, which I think is actually what you want, is to do the following:
Code: [ Select ]
<?
$date = date("m.d.y");
echo "<img src=\"images/$date.jpg\">";
?>
  1. <?
  2. $date = date("m.d.y");
  3. echo "<img src=\"images/$date.jpg\">";
  4. ?>

This would make it so you only have to name the images for example: 4.24.04.jpg and put them in the folder images. You could change the filetype or how you want the date to be displayed to fit your custom.
See: http://us4.php.net/manual/en/function.date.php for information on how to customize the date function.
Hope I was of some help.
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Mar 24, 2004
  • Posts: 1855
  • Loc: Uk
  • Status: Offline

Post April 25th, 2004, 1:39 am

Yep I'd personally go with scorpius.

You could also modify that to have a default image, with a different image for certain days, like the google holiday titles (and you could set it up days in advance with no real effort involved
CSS website design tutorials
  • pony
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Feb 27, 2004
  • Posts: 7
  • Status: Offline

Post April 25th, 2004, 5:03 am

Yes. Scorpius's worked fine. Thank you very much.
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Joined: Mar 20, 2004
  • Posts: 401
  • Loc: Scorpion Hole
  • Status: Offline

Post April 25th, 2004, 1:16 pm

Heh, good hope it'll do you some good.

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 128 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.