SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Nov 15, 2006, 19:49 #1
- Join Date
- Dec 2005
- Location
- xi an city,ShanXi Province,China
- Posts
- 136
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How to make random stuff at my site?
I see some sites display random videos,games etc.How to make this effect?
One world,One dream
-
Nov 15, 2006, 21:10 #2
- Join Date
- Jul 2005
- Location
- West Springfield, Massachusetts
- Posts
- 17,290
- Mentioned
- 198 Post(s)
- Tagged
- 3 Thread(s)
random array value
If you put whatever you want to have as possible items into an array, you can use random() to access an item from the items. You don't need to "hard code" the array. You can populate it from a database query, or use file system functions too.
Big Change Coming Soon - if you want your PMs save them now!
What you need to do to prepare for our migration to Discourse
A New SitePoint Forum Experience: Our Move to Discourse
-
Nov 16, 2006, 00:19 #3
- Join Date
- Mar 2005
- Location
- Ukraine
- Posts
- 1,403
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You can do that on the database level:
Code:SELECT FROM table_name ORDER BY RAND() LIMIT items_count
Bookmarks