Results 1 to 2 of 2

Thread: Asking for making random array for displaying on the page

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2002
    Location
    Viet Nam
    Posts
    142

    Asking for making random array for displaying on the page

    Random for displaying rows from database
    I did query and get all of the rows in my table test . Each row in my database include fields like this : id , ask , a , b , c , d , answer . All are 7 fields . When display on a page i want it to be displayed in inorder , in random the with the field ID and in the row the 4 fields a,b,c,d are all displayed in an inorder too . Telling this is so hard to imaging so i am trying to put an example here . This is a projest of mine , doing the work of a test with a question and 4 choies for ppl to choose the answer .

    Display1 :
    1. Question A
    a. Choice a
    b. Choice b
    c. Choice c
    d. Choice d
    2 Question B
    a. Choice d
    b. Choice a
    c. Choice b
    d. Choice c
    ..................
    Display 2
    1. Question B
    a. Choice d
    b. Choice a
    c. Choice c
    d. Choice b

    2 Question A
    a. Choice b
    b. Choice c
    c. Choice a
    d.Choice d
    ......................................

    This mean that when a user visit this page , they can see this order , but another one visit this page it will change into another oder with the same question thy can see the oder of the questions are not the same .
    Have anyone has gotten over this before please tell me what to do . Maybe now i need your algorithsm

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Try:

    Code:
    SELECT * FROM table_name ORDER BY RAND()
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

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



Click Here to Expand Forum to Full Width