We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
I need a code to allow me to have alternate; images each time my homepage is loaded
Topic Started: Jan 26 2005, 02:50 PM (338 Views)
madonnasworld
Member
[ *  * ]
anyone have it?
thanku so much
Offline Profile Quote Post Goto Top
 
FearKiller
Member Avatar
www.drewscripts.com
[ *  *  *  *  * ]
So you want a code that will load a different image if the primary image fails to load, correct?
Offline Profile Quote Post Goto Top
 
Zach
Member Avatar
Missjayness
[ *  *  *  *  * ]
No, I tinhk he means something that just randomly chooses a different logo every time the page is loaded. Kinda like this: audioscrobbler.com (the random text near the logo) but with images.
Offline Profile Quote Post Goto Top
 
Jory
Member Avatar
Member
[ *  *  *  *  *  * ]
dunno exact code, but its something like:

img = rand(1000)
if(img==1){<img src=img1}
else{ if(img==2){<img src=img2}
else{ if...............

rand(x) takes a random number between 0 and x
(again, not exact code, but it does work (have file with code like this at school, if i remember, all post it) )
Offline Profile Quote Post Goto Top
 
FearKiller
Member Avatar
www.drewscripts.com
[ *  *  *  *  * ]
deat
January 26, 2005 03:47 PM
No, I tinhk he means something that just randomly chooses a different logo every time the page is loaded. Kinda like this: audioscrobbler.com (the random text near the logo) but with images.

Yea well he said "alternate" so I think he would mean alternate not random. Well, if you do want a random image code and in PHP, seeing as you didn't post what language you wanted it in either, then here it is.
Code:
 
<?php

$images = array ("image1.png", "image2.gif", "image3.jpg");
$random = array_rand ($images);

?>

<img src="<?php echo $images[$random] ?>" alt="random image" />
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply