Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Auto create names
10-04-2013, 02:52 PM #1
- Join Date
- Jan 2011
- Thanked 0 Times in 0 Posts
Auto create names
I'm looking at making the following script.
I want to have 3 text files
1st will have 100's of Forenames.
2nd will have 100's of Surnames.
3rd will have 100's of countries.
The script will pick completly random from each text and display on a webpage.
It should run continuesly and show many 20 results at a time and then if someone refreshed it would show maybe 2 or 3 new ones and still have the others
Lets say a new one should be posted every 5 minutes. But 20 would be displayed at a max. Meaning if looked at the web page.. you'd see 20 names/country -- if you waited 5 minutes and refresh you'd still see 20, But there would be 1 new one at the bottom.
Is this easy to do ?
10-04-2013, 03:37 PM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,662 Times in 2,631 Posts
Is it easy? Sure. Just write a bunch of random access files, and use an identifier that dictates the number of entries. Jump randomly between 1 and the max records to the appropriate field and pick it out. Drop these into a new file, and each time a page loads check the timestamp of the file to see when it was modified, and shift out the first entry and push a new one on using the same scanning method prior. This file could be serialized to make it easier since you can just leave it as an arraylist or, for ease of push/pop, a linkedlist.
I'd presume you'll be using JSP for this if you want it on a webpage, and I can't help with that as I don't program either JSP or servlets.PHP Code:
header('HTTP/1.1 420 Enhance Your Calm');