random results

Results 1 to 3 of 3

Thread: random results

  1. #1
    cindy Guest

    Default random results

    Hello boys,<BR><BR>I have retrieved and displayed records selected through a search form from a database. The records display in the order they are located in the database. I want to display them randomly. Can anybody help!

  2. #2
    Join Date
    Dec 1969

    Default RE: random results

    Hi.<BR><BR>I dont know how to (if possible) display it as random but you can use ORDER BY to change the display order from the databas but then you get it in some sort of order instead.<BR><BR>Ex:<BR>Set RS = DConn.Execute ("SELECT * FROM TheTable ORDER BY Name DESC;")<BR><BR>this will use the Name-field to sort and the sort order will be Descending.<BR><BR>Hope it helps some.

  3. #3
    Rokea Guest

    Default RE: random results

    Here is the only way i can figure out:<BR><BR>Supose you get 15 records back from your database:<BR>Create an Array of 15 integers.<BR>Then do a randomize, then:<BR>Int((upperbound - lowerbound + 1) * Rnd + lowerbound)<BR><BR>Where upperbound is 1 and lowerbound is 15.<BR><BR>Store that result in your Array (First position). <BR><BR>Then do that Randomize - Rnd thing again. <BR><BR>If the number you get is different from the numbers previously stored in your array, then insert it at the last position in your array, if it as an equivalent in your array, dont keep this number.<BR><BR>Repeat Randomize-Rnd Thing... <BR><BR>Go on until you&#039v got number 1 through 15 of your array filled..<BR><BR>Now that youv got your array filled, Make a little loop-function which writes on the page the links following the integers in your array.<BR><BR>Hope this helps

Posting Permissions

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