Sorry for this e-mail, When I wrote this, my e-mail server was down, and it was archived for sending. By the time the e-mail server was restored, I had solved this problem.
- TheHeadSage ----- Original Message ----- From: "TheHeadSage" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, December 07, 2003 2:39 PM Subject: [PHP] Random Numbers.. > Hey, > > I've got a script which used to generate a random quote. It worked fine > untill this problem occurred.. > > Say we have 4 quotes with QuoteID's of 1 through to 4 > The script would grab a number of rows, and generate a random number > between 1 and this value (being 4 in this case) This worked fine untill, > one of the quotes was removed and another added, leaving 4 quotes once > again, but the last one had an ID of 5. The problem is the Random number > generated is between 1 and 4, so the final quote is never shown.. > > I tried using the RAND() function in the MySQL statement it's self, but > it's not random enough... > > Then I thought of doing this: > > Select all the Quote ID's from the DB. > Store them in an Array. > Generate a random number between 1 and the last ID. > If the Random Number matches a Quote ID, then display the quote, > otherwise Generate another > > But I couldn't get the code to work. Any suggestions on either how to > write the above, or made the MySQL RAND() function, more random? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php