Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Lake Forest, CA
    Posts
    259
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Random Selection from database...

    Hi everyone!

    Lets say I have 6 items in my database.

    And I want to randomly select 1 and display it, how would I do this?
    The Wizzard
    OC Motor Cars | OC Auto Sports (Coming Soon!)

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    676
    Thanks
    1
    Thanked 0 Times in 0 Posts
    wiz...
    just a checkout® this link...
    http://www.webmasterworld.com/forum47/266.htm

  • #3
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    One way I know of using ASP... I'm still not up on all the functions you can do in SQL so there might be a way to do it there.

    but here is a asp way:

    Code:
    Randomize
    Dim intRandom, strQuery
    intRandom=int((rnd*MaxValue)+MinValue)
    
    strQuery="SELECT * FROM mytable WHERE ID='"&intRandom&"';"
    Try that.
    OracleGuy


  •  

    Posting Permissions

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