Database Articles

  Home arrow Database Articles arrow Page 5 - Adding a Poll to Your Web Site

Adding a Poll to Your Web Site
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 203

    Table of Contents:
  • Adding a Poll to Your Web Site
  • Setting the Stage
  • Creating the Form
  • The Complete showvotes.php
  • Expanding the Poll
  • Polling Accuracy



    Adding a Poll to Your Web Site - Expanding the Poll

    (Page 5 of 6 )

    What if you want to create a new poll each week, or a 25-question survey, or even a trivia quiz? Simple! Create a second table, poll_questions, to hold all the questions. Add an index to poll_answers to reference the question number.

    The SQL for poll_questions might look like this:

    CREATE TABLE poll_questions
     question VARCHAR(35) NOT NULL)

    And the new poll_answers:

    CREATE TABLE poll_answers
    (poll_num INT NOT NULL, choice INT NOT NULL,
     activity VARCHAR(35) NOT NULL, votes INT DEFAULT 0,
     PRIMARY KEY (poll_num, choice))

    You could also add date fields to poll_questions to set a starting and ending date for each question to be displayed. If you're designing a quiz, you could add a field to poll_questions to indicate which answer is correct.

    More Database Articles Articles
    More By Codewalkers

    blog comments powered by Disqus


    - MariaDB, a MySQL Alternative, Opens Foundati...
    - Oracle Supporting HP Itanium Again, Finally
    - Completing a Book Inventory Management System
    - Uploading Images for a Book Inventory Manage...
    - Finishing the Add Book Story for a Book Inve...
    - Integration Testing for a Book Inventory Man...
    - User Stories for a Book Inventory Management...
    - Unit Testing a Book Inventory Management Sys...
    - Testing a Book Inventory Management System
    - Implementing Models for a Book Inventory Man...
    - Book Inventory Application: Publishers and B...
    - Handling Publishers in a Book Inventory Mana...
    - Publisher Administration for Book Inventory ...
    - Book Inventory Management
    - Using the SQL Reference Manual

    Developer Shed Affiliates


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