select all and
use
mysql_data_seek($result, rand(mysql_num_rows($result) - 1));
$row = mysql_fetch_assoc($result);

and there, your random row is returnd, that should be easy enough :) and it
should work

-- 
Luke

"Theheadsage" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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

Reply via email to