22.1.7 Building a better pollThis is NOT the latest copy of this book; click here for the latest version.
We have looked at three levels of poll difficulty, but there is still a lot more to do if you want to. We're not going to cover it here, because this book is not just about poll writing, but why not try extending your poll with these ideas:
-
Figure out which parts of the tables should be indexed for maximum performance. Remember the rule about indices: have too many and you will end up slower than without any.
-
Add a click through link to see the results without voting. This is fairly straightforward, as the actual voting process requires a vote to be set - simply exclude this.
-
Write a breakdown of the results using a demographic, or perhaps using the DateVoted number. There is lots to try out here!
-
Write code to let people add their own options. You probably will not use this in a live site, but it is good to practice.
-
Make the results page draw a graph. The easiest way to do this is using a horizontal bar chart, using a simple picture for each 1% of the total an option holds, e.g. a vote with 25% would have 25 of these pictures lined up side by side)
There is lots you can do with opinion polls, and we've only scratched the surface here - they are very easy to write, and consequently very easy to toy around with if you have new ideas.
|
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.
My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!
|