Name: BigShow Date: October 8, 2006 at 19:57:17 Pacific Subject: voting script OS: xp CPU/Ram: pentium 4 Model/Manufacturer: dell
Comment:
I have a question about creating a script that would allow someone to go to my website and vote on something. For example, if I had a survey on there for the best hitter of all time and gave 5 choices, i would want people to vote and I would want the results to show up in some sort of graph automatically and immediately, if possible. Would I have to make a small database? Any help would be appreciated.
Not necessarily. You could save the results in a text file. Just read the text file to display the results. When someone posts their vote, open the text file and change the appropriate results and save it back to the file.
However, doing this does have it's problems. If, for instance, two people submit their votes at very close to the same time you could end up corrupting the file.
Michael let me revise the question as I figured exactly what i want, I want to give choices to vote on, i want someone to vote on then (example vote the best of 5 ) and have this compute automatically and every hour or so have it update the order of the choices, or maybe even update the order automatically. I dont want to go through emails tirelessly, i figure php and a database, if u agree have you seen any pre made scripts like this or close to it.
Again, the answer is yes. You can use a database or you could use a flat file. You can get as complex or as simple as you wish.
For example, if you had a vote for the best actors ever and you had 5 options, the txt file might contain the following (minus the lines): ------------------- Mel Gibson: 25 Leroy Jenkins: 2 William Shatner: 0 Tom Hanks: 45 Donald Sutherland: 8 -------------------
When soeone makes a vote you have the PHP open the file and increment the value of the entry they selected by 1.
When displaying the results (or to order the vorting options) just have the PHP open the file and read the contents. Then display the results accordingly.
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE