SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot steven012's Avatar
    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

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    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.

  3. #3
    An average geek earl-grey's Avatar
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •