* Thus wrote Burrito Warrior ([EMAIL PROTECTED]):
>
> This would:
> /* selecting a random record, where n = 1. Works fine on small tables */
> mysql> SELECT value FROM table ORDER BY RAND() LIMIT n;
>
> /* selecting a random record. This is good on large tables if numbering
> sequence is used *
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,
>
>
CTED]
Subject: [PHP] Re: Random Numbers..
Theheadsage wrote:
> 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
Theheadsage wrote:
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)
51 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Random numbers in a cronned script?
Yes, you're right about that point since the seed in most cases is computed
from system time => increasing probability of having same number @ the same
request time...
you can change the seed with the time()
Yes, you're right about that point since the seed in most cases is computed
from system time => increasing probability of having same number @ the same
request time...
you can change the seed with the time() too (not all days are the same).
hope to hear others' opinions too.
Elias
"Leif K-Brook
You should call mt_srand((double) microtime() * 100) once, and only
once, in any given script.
--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmus
[EMAIL PROTECTED] (Nikola Veber) wrote:
> Hi !
> I'm having troubles with the random numbers. When I create a number witm mt_rand()
> I always get the same number on my local server. I need this stuff to ranomly
>display
> some text, and I'd like to have another value of the random number
8 matches
Mail list logo