Page 1 of 1
how to change random content to repeating
Posted: Mon Oct 20, 2008 9:31 am
by dweezel44
Hi - I have images randomly cycling on a home page of a site that i am working on and would like to change it so it goes in order and then repeats. I am stumped and can't find the correct term to use.
Here is the code I am working with.
$random_content="random.htm";
$random_content=file("$random");
$display=rand(0, sizeof($random)-1);
echo $random_content[$display];
also this code:
/*
generate a random number between zero
and the number of quotes minus one
*/
$rand = rand(0, (count($quotes)-1));
// output the random quote
echo $quotes[$rand];
Any help would be appreciated
Thank you!

Re: how to change random content to repeating
Posted: Mon Oct 20, 2008 9:47 am
by aceconcepts
Re: how to change random content to repeating
Posted: Mon Oct 20, 2008 9:53 am
by onion2k
How is sorting going to help? The issue here is with the stateless nature of the internet. You need to record which item was last displayed to the user and use that value to find the next one ... I suggest you read up on "sessions".
Re: how to change random content to repeating
Posted: Mon Oct 20, 2008 9:56 am
by aceconcepts
Are we not talking about random integer values he wants ordered?
Re: how to change random content to repeating
Posted: Mon Oct 20, 2008 10:18 am
by onion2k
I think he wants a quote on the page that starts on Quote 1, then increments through all the available quotes, and loops when it gets to the end. A value denoting which quote the user has last seen stored in the session that increments on each page load is the simplest solution.
Re: how to change random content to repeating
Posted: Mon Oct 20, 2008 10:32 am
by dweezel44
thank you. i will research sessions and let you know how it works out. thanks all!

Re: how to change random content to repeating
Posted: Mon Oct 20, 2008 10:37 am
by aceconcepts
onion2k wrote:How is sorting going to help?
Too right - oops my bad

Re: how to change random content to repeating
Posted: Mon Oct 20, 2008 10:40 am
by dweezel44
aceconcepts - i am talking about random integer values which i would like to change to in order and repeating or just repeating. What do you suggest i change it to or research on.
Thanks

Re: how to change random content to repeating
Posted: Mon Oct 20, 2008 11:28 am
by VladSun