Computer Science Canada Requesting a random site for site ring. |
Author: | agnivohneb [ 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). |
Author: | Dan [ 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. |
Author: | octopi [ Thu Jan 10, 2008 11:07 pm ] |
Post subject: | Re: Requesting a random site for site ring. |
You might want to read and consider using the following: http://www.gorilla3d.com/v4/index.php/blog/entry/35 or http://www.greggdev.com/web/articles.php?id=6 They'll help you make a solution that will be quick, (quicker than using the method already suggested) which is important if you plan for your site/webring to have many visits. |
Author: | agnivohneb [ 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. |