Home arrow PHP arrow Page 3 - Democracy, The PHP Way

Design View - PHP

One of the simplest and most popular add-ons to a Web site is anonline poll, allowing visitors to vote on hot-button issues. In thisarticle, find out how PHP can be used to build a powerful, good-lookingonline poll for your Web site, and also learn a little bit about its imageand cookie manipulation functions.

TABLE OF CONTENTS:
  1. Democracy, The PHP Way
  2. The Plan
  3. Design View
  4. Start Me Up
  5. Vote Now, Or Forever Hold Your Peace
  6. The Number Game
  7. Down Memory Lane
  8. Cookie-Cutter Code
  9. Adding More...
By: Vikram Vaswani, (c) Melonfire
Rating: starstarstarstarstar / 24
April 16, 2001

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
This is a good time for you to download the source code, so that you can refer to it throughout this tutorial (you will need a Web server capable of running PHP and a mySQL database in order to run the application).

poll.zip

After spending an hour looking out the window and another hour at lunch (hey, these are billable hours!), this is the database structure I came up with.

# # Table structure for table 'poll' # poll.sql in the source archive CREATE TABLE poll ( id int(10) unsigned NOT NULL auto_increment, question varchar(255) NOT NULL, response1 varchar(255) NOT NULL, response2 varchar(255) NOT NULL, response3 varchar(255) NOT NULL, votes1 int(10) unsigned DEFAULT '0' NOT NULL, votes2 int(10) unsigned DEFAULT '0' NOT NULL, votes3 int(10) unsigned DEFAULT '0' NOT NULL, date date DEFAULT '0000-00-00' NOT NULL, PRIMARY KEY (id) ); # # Column descriptions: # # id - a unique identifier for each poll/question # question - the poll question # response1 - possible response #1 # response2 - possible response #2 # response3 - possible response #3 # votes1 - number of votes for response #1 # votes2 - number of votes for response #2 # votes3 - number of votes for response #3 # date - date on which poll was posted # Just to get things started, I also INSERTed the first question into the database, together with three possible responses. # # Dumping data for table 'poll' # INSERT INTO poll (id, question, response1, response2, response3, votes1, votes2, votes3, date) VALUES ( '1', 'The Oscar for Best Picture should go to...', 'Gladiator', 'Erin Brockovich', 'Traffic', '0', '0', '0', '2001-03-07');


This article copyright Melonfire 2001. All rights reserved.

 
 
>>> More PHP Articles          >>> More By Vikram Vaswani, (c) Melonfire
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap

Dev Shed Tutorial Topics: