|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
rotating search results
I am working on a business directory currently and I was wondering how could I go about changing the ordering of the search results so that for example:
I have a list of business; ABusiness BBusiness Cbusiness Dbusiness and what I would like to do is have a rotating or random result ordering so that when you go to the site, one time it will order them like so ABusiness BBusiness Cbusiness Dbusiness but the next you or some one else visits the site it will order them like: BBusiness Cbusiness Dbusiness ABusiness and so on for the list so that the business that start with 'Z' will not always be at the bottom of the list. Any suggestions. Thank you |
|
#2
|
|||
|
|||
|
I recommend looking into randrange().
|
|
#3
|
|||
|
|||
|
would that work with a access database, or would it be just for a SQL database?
|
|
#4
|
|||
|
|||
|
Whatever the function is in Access that generates a random number, you should be able to use in the ORDER BY clause to force the query to come back in a random order.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#5
|
|||
|
|||
|
I was not able to find the random function for access that actually made the results random but I was able to put together a work around for the time being:
Code:
<cfloop condition="ListLen(business_list, '%') lt get_business.recordcount"> <cfset rand_num = #RandRange(1, get_business.recordcount)#> <cfset next_business = #get_business.bID[rand_num]#> <cfif NOT ListFind(business_list, next_business, "%~")> <cfset business_list = #business_list# & "%" & #get_business.bID[rand_num]# & "~" & #get_business.bName[rand_num]# </cfif> </cfloop> Thank you |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > rotating search results |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|