Hudzilla.org - the homepage of Paul Hudson
Contents > Practical PHP > Creating a poll Wish List | Report Bug | About Me ]

22.1.7     Building a better poll

This 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.





<< 22.1.6 Making the final poll   22.2 Creating a guestbook >>
Table of Contents
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!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
A PHP User - 06 Sep 2008

Rather than having 25 individual images side by side, Its probably better to just change the width accordingly. If you want something with 100% 200 pixels wide, a answer with 25% would be 50 pixels wide.



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is eight plus three?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow