Forum Moderators: phranque

Message Too Old, No Replies

Random page generator

Setting up a link to a random page on my site

         

spharalsia

2:18 pm on Nov 17, 2005 (gmt 0)

10+ Year Member



Can any of you programming wizards suggest a relatively simple way to create a link that brings users to a random page on my site? I see that Wikipedia has a feature like this, and the code includes "special:random" in the link tag, but I suspect there's more to it than that....

Thanks in advance.

MrPatate

3:11 pm on Nov 17, 2005 (gmt 0)

10+ Year Member



If your website is in a database and that the navigation is in a table in some way, you can select a random record with mysql using ORDER BY random() LIMIT 1

How precisely you implement it depends on the structure of your database.

zulu_dude

9:15 am on Nov 18, 2005 (gmt 0)

10+ Year Member Top Contributors Of The Month



If your site isn't contained in a database, I'm sure you could do a similar thing with javascript... just stick all the possible URLs in an array, then use an 'onclick' event handler to randomly select a URL from the array.

Obviously this would be a serious mission if you have an enormous site.

spharalsia

10:05 pm on Nov 19, 2005 (gmt 0)

10+ Year Member



These are helpful answers. I think I'll look into hiring someone to write a simple javascript for me. Thanks, folks!