ASP Hosting sale!
Double disk space and transfer for FREE!
Limited time offer! Act Now!

aspdev | articles | tutorials | forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pulling random entry from a file

 
Post new topic   Reply to topic    ASPdev.org Forum Index -> SQL Programming (MS SQL Server, MS Access, MySQL)
View previous topic :: View next topic  
Author Message
twinkle



Joined: 31 Jan 2006
Posts: 79

PostPosted: Tue Jan 31, 2006 9:17 pm    Post subject: Pulling random entry from a file Reply with quote

I have a database of quotes and I want to pull a random entry from the database but I would like the random input to be seeded by user interaction, be it a single keystroke or even better a word.

Does anyone have any suggestions on how to implement this?
_________________
I shine
Back to top
View user's profile Send private message
mikelbeck



Joined: 31 Jan 2006
Posts: 18
Location: Lawn Guyland, Noo Yawk

PostPosted: Tue Jan 31, 2006 10:18 pm    Post subject: Reply with quote

What do you mean by "seeded by user action"? You want a user to enter something and then you pull a quote that matches?
Back to top
View user's profile Send private message Visit poster's website
paul



Joined: 11 Oct 2004
Posts: 128

PostPosted: Wed Feb 01, 2006 1:04 am    Post subject: Reply with quote

You can use the current time as a unique seed. I mean the time the user clicked...
_________________
World Countries | Survival Skills
Back to top
View user's profile Send private message
twinkle



Joined: 31 Jan 2006
Posts: 79

PostPosted: Wed Feb 01, 2006 6:29 am    Post subject: Reply with quote

mikelbeck wrote:
What do you mean by "seeded by user action"? You want a user to enter something and then you pull a quote that matches?


Paul mentions the time as a seed, and that would work, but I want the user to feel like they are having an impact on the randomness. So I want to have them enter a short text string of whatever they want and use that to seed the random number that then pulls the entry from the database.

I guess I could just lie to the user and use the time, but I would rather just have the value of the text work as the seed, if possible.
_________________
I shine
Back to top
View user's profile Send private message
mikelbeck



Joined: 31 Jan 2006
Posts: 18
Location: Lawn Guyland, Noo Yawk

PostPosted: Wed Feb 01, 2006 11:21 am    Post subject: Reply with quote

Say you have 100 records in your database, you could use the seconds from the time the user entered their information to pull a record.
Back to top
View user's profile Send private message Visit poster's website
twinkle



Joined: 31 Jan 2006
Posts: 79

PostPosted: Wed Feb 01, 2006 1:14 pm    Post subject: Reply with quote

mikelbeck wrote:
Say you have 100 records in your database, you could use the seconds from the time the user entered their information to pull a record.


Hmm.. Okay I guess that would work. Can I not just use the ascii value (or whatever) of the text and add it together or something? Would that be possible. I honestly do not know why I am going to all the trouble, nobody would actually know except for me, but I would feel better if it worked as I presented it.
_________________
I shine
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ASPdev.org Forum Index -> SQL Programming (MS SQL Server, MS Access, MySQL) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group

SQL Tutorial