non-random image rotation in php

  • pony
  • Newbie
  • Newbie
  • pony
  • Posts: 7

Post 3+ Months Ago

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?
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

like a different text for each day of the week?
  • pony
  • Newbie
  • Newbie
  • pony
  • Posts: 7

Post 3+ Months Ago

yes. exactly. different text and different image for each day of the week
  • Yellow19
  • Born
  • Born
  • Yellow19
  • Posts: 4

Post 3+ Months Ago

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
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

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
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

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
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

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
  • pony
  • Newbie
  • Newbie
  • pony
  • Posts: 7

Post 3+ Months Ago

Yes. Scorpius's worked fine. Thank you very much.
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

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 29 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.