![]() |
how random are the spotlights?
I seem to see the same quote by Dr. Bot "The big lesson we learned ... our past does not limit our future, that superior attitude will beat out big budgets." several times per session. I've even seen it on 3 consecutive pages. So...just how random are the spotlights?
|
Code:
SELECT * FROM cd_spotlight WHERE approved>0 ORDER BY RAND() LIMIT 1[EDIT]ok, its changed. Hopefully it'll be a bit more random.[/EDIT] |
How did you change it? I noticed on one of my sites long ago that rand really doesn't work too well like that.
|
Pulled in the whole data set, didn't limit it to 1 row. I then used php's rand() function, and took a random number from 1->[# of records in dataset]. And then showed that row.
Hopefully random row of a randomly sorted dataset will be a bit more random. :D :shrug: |
Might you need to use srand? Taking a random number twice won't do any good if it starts with the same seed value.
|
One's from mysql's 'ORDER BY RAND()', the other's from php's rand() function.
Oh, and from php.net's man page for srand(). Quote:
|
my bad. I'm just used to C's rand() that does nothing useful uless you seed it. Sorry about that.
|
Quote:
|
| All times are GMT -5. The time now is 02:36 PM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi