Page 1 of 2

help me please with randomization

Posted: Mon Mar 29, 2004 11:41 am
by jacka18l
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

Posted: Mon Mar 29, 2004 11:54 am
by JohnDigweed
Why not research it? There are plenty of tutorials out there.

No one is going to make you a script, for free that is.

Re: help me please with randomization

Posted: Mon Mar 29, 2004 12:18 pm
by TheBentinel.com
jacka18l wrote:i need a script to randomize which picture appears.
The stuff here should give you a good start:

http://www.hotscripts.com/PHP/Scripts_a ... index.html

Posted: Mon Mar 29, 2004 2:47 pm
by John Cartwright
har har har.......

there should be a sticky saying when in doubt look at hotscripts.com

Posted: Mon Mar 29, 2004 2:48 pm
by Illusionist
lol

Posted: Mon Mar 29, 2004 3:15 pm
by m3mn0n
There is.

Posted: Mon Mar 29, 2004 5:05 pm
by pickle
What do you mean by it will be "getting them from a link". Are all the images going to be sent as a string? If you DO want to read a directory, its super easy.

Posted: Mon Mar 29, 2004 5:14 pm
by Illusionist
BUT he DOESN'T want to read them from a directory. he DOES want to get them from a link.

Posted: Mon Mar 29, 2004 5:21 pm
by pickle
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.

Posted: Mon Mar 29, 2004 6:06 pm
by Illusionist
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!

Posted: Mon Mar 29, 2004 6:29 pm
by JohnDigweed
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">

Posted: Mon Mar 29, 2004 6:35 pm
by markl999
Maybe he/she will come back one day and clarify it all? ;)

Posted: Mon Mar 29, 2004 7:39 pm
by d3ad1ysp0rk
7 hours and you're already jumping down the guy's throat mark? :P

maybe he's sleeping! lol

Posted: Tue Mar 30, 2004 10:32 am
by jacka18l
*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.

Posted: Tue Mar 30, 2004 11:25 am
by Illusionist
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')