• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

html code to display a random url from a database

Cpus

Senior member
Is there a simple way to write html code to display a random url from a database? Thanks.
 
I know how to create html code with a button that takes you to a specified url but I want th url to be random each time
 
I know how to create html code with a button that takes you to a specified url but I want th url to be random each time

How random do you want it to be? Each character random or a specific part of the URL to be random characters?
Is the possibility of getting an invalid return acceptable?

Otherwise, I would suspect that you have to create a list of valid URLs and then randomly choose one of them.
 
How random do you want it to be? Each character random or a specific part of the URL to be random characters?
Is the possibility of getting an invalid return acceptable?

Otherwise, I would suspect that you have to create a list of valid URLs and then randomly choose one of them.

yeah that is what i mean. a list of valid urls. I need to know how to get it to pick a random url from a database not just obe specified url.
 
Last edited:
Seconded, my first thought was using JavaScript (or jQuery) to randomly access a list of URLs. I figured just an array but an XML file would be better, though I didn't realize jQuery could do that.
 
Load the url list of N items
Use a random method for your language to get an index from 0 to N-1
Get the url from the list position corresponding to the index.
 
Back
Top