Requesting a random site for site ring.
Author |
Message |
agnivohneb
|
Posted: Thu Jan 10, 2008 1:30 pm Post subject: Requesting a random site for site ring. |
|
|
I need help for getting requesting a random site form a MySQL DB and then go to it.
Basically the DB is setup like this. Two tables one wr__ring and the other wr__site
wr__ring
Holds the information for the rings
The fields include: id (key), name, description, img, allowjoin
This table is really not important in this question. I just want to let you know there are more than one ring.
wr__site
Holds the information for all the sites
The fields include: id (key), ring, name, status, url, description, password, img, hits
The only fields important are id [int(11)], ring [int(11)], url [varchar(255)]
Basicly I need to select a random row from wr__site where ring equals the given ring id supplied
I was thinking of just picking a random number and match it with the id but there will not be a constant sequence of numbers, it could go 1,2,4,11,13,14 ... (from some being deleted and ring).
Now I know very little about PHP and MySQL so when it comes to random in this language I am lost.
Any Ideas on how I can get started? or even a sample code (explained of course). |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Dan
|
Posted: Thu Jan 10, 2008 9:07 pm Post subject: RE:Requesting a random site for site ring. |
|
|
SELECT * FROM wr__site ORDER BY RAND() LIMIT 1
I think that whould do it, but i have not tested it. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
octopi
|
|
|
|
|
agnivohneb
|
Posted: Sat Jan 12, 2008 1:21 am Post subject: RE:Requesting a random site for site ring. |
|
|
Thanks dan that should work I will give it a try
Sorry octopi but I am looking for simple. and thats not simple, well to me at least. If this will not work then I will give that a shot. |
|
|
|
|
|
|
|