OutFront Forums
     Home    Register     Search      Help      Login    

Follow Us
On Facebook
On Twitter
RSS
Via Email

Recent Posts
Todays Posts
Most Active posts
Posts since last visit
My Recent Posts
Mark posts read

Sponsors
Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.
Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.
Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

 

Random Results in A Searchy Query HELP!!

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP, PHP, and Database >> Random Results in A Searchy Query HELP!!
Page: [1]
 
webgyrl

 

Posts: 52
Joined: 2/9/2009
Status: offline

 
Random Results in A Searchy Query HELP!! - 10/28/2009 18:51:42   
Hey guys,
I have a site that list people and their skills and i wanted every time someone ran a search based on their select criterias the order of the results would change. In other words i want all the people to get a fair shot at being on the top of the list. Is their anyway i can make the results show up in random order every time or at least half the time? am using asp and frontpage.
TexasWebDevelopers

 

Posts: 722
Joined: 2/22/2002
From: Dallas, TX
Status: offline

 
RE: Random Results in A Searchy Query HELP!! - 10/29/2009 9:21:28   
Randomizing record retrieval is a bit more complicated than it might seem at first blush. First, you need to find a cound of the records..you cannot randomize without that information:
cnt1 = cnt
rndMax = cnt
If CInt(5) < cnt Then
cnt1 = CInt(5)
End If

Then we need to create a random number based on the count:
RndNumber = Int(Rnd * rndMax)

Next its time to randomize the results
If (InStr(1, str1, "," & RndNumber & "," ) = 0) Then
str1 = str1 & RndNumber & ","
cnt1 = cnt1 - 1
Rs.MoveFirst
Rs.Move RndNumber
str = str & Rs("id") & ","
End If
Loop

The full code and example are here:

http://www.texaswebdevelopers.com/examples/retrieverandomrecords.asp

_____________________________

:)

Follow us on TWITTER

(in reply to webgyrl)
Page:   [1]

All Forums >> Web Development >> ASP, PHP, and Database >> Random Results in A Searchy Query HELP!!
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts