help me please with randomization
Moderator: General Moderators
help me please with randomization
i need a script to randomize which picture appears.
the script will NOT grab the images form a folder but it will get them from a link.
thanks
the script will NOT grab the images form a folder but it will get them from a link.
thanks
-
JohnDigweed
- Forum Newbie
- Posts: 18
- Joined: Sun Mar 28, 2004 6:24 pm
- Location: root/user/hell
-
TheBentinel.com
- Forum Contributor
- Posts: 282
- Joined: Wed Mar 10, 2004 1:52 pm
- Location: Columbus, Ohio
Re: help me please with randomization
The stuff here should give you a good start:jacka18l wrote:i need a script to randomize which picture appears.
http://www.hotscripts.com/PHP/Scripts_a ... index.html
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
I'm just unsure of what he means by getting them from a link. Will the user click a link which will generate the random image? Will the image names be sent as post variables?
In the script that finds the random image, how does it get the file names to choose from?
In any event, it's probably easiest to put all the filenames in an array, then call array_rand() to get a random element.
In the script that finds the random image, how does it get the file names to choose from?
In any event, it's probably easiest to put all the filenames in an array, then call array_rand() to get a random element.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
i think that is what he is doing. he ahs the image links in an array maybe, and wants to know how t get a random one. But he may have them all in a text file. Or maybe one link has a million images and he wants to know how o get one. I dont know. He really didn't say, so its kind of hard to help him!
-
JohnDigweed
- Forum Newbie
- Posts: 18
- Joined: Sun Mar 28, 2004 6:24 pm
- Location: root/user/hell
I think I know what he means. He has a bunch of links to images such as
http://www.yourdomain.com/1.gif
http://www.yourdomain.com/2.gif
http://www.yourdomain.com/3.gif
http://www.yourdomain.com/4.gif
http://www.yourdomain.com/5.gif
http://www.yourdomain.com/6.gif
What he wants to is display these images randomly. Like, if $randimage represented a random image, he would want to display :
<img src="$randimage">
http://www.yourdomain.com/1.gif
http://www.yourdomain.com/2.gif
http://www.yourdomain.com/3.gif
http://www.yourdomain.com/4.gif
http://www.yourdomain.com/5.gif
http://www.yourdomain.com/6.gif
What he wants to is display these images randomly. Like, if $randimage represented a random image, he would want to display :
<img src="$randimage">
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
*was sleeping* lol
yeah i mean like
(excuse the crappy code which is not actually a code at all)
"
array of images
http://www.com/image1.jpg
http://www.com/image2.jpg
http://www.com/image3.jpg
http://www.com/image4.jpg
http://www.com/image5.jpg
get random file and display here
"
not code atall really, but what i want it to do.
yeah i mean like
(excuse the crappy code which is not actually a code at all)
"
array of images
http://www.com/image1.jpg
http://www.com/image2.jpg
http://www.com/image3.jpg
http://www.com/image4.jpg
http://www.com/image5.jpg
get random file and display here
"
not code atall really, but what i want it to do.
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
so you have an array of links to images??
Code: Select all
$images = array('http://www.com/image1.jpg','http://www.com/image2.jpg','http://www.com/image3.jpg')