PHP MySQL Voting system Development Example tutorial (1/4)

Source: Internet
Author: User
Tags php mysql create database

Let's analyze the process first.

One, database tutorial,

Second, database file dbconn.php

Three, vote.php voting page

Four, voting function page vote_add.php

Five, view all voting data viewpoll.php

Now let's look at the database structure.

The code is as follows Copy Code

Drop database if exists vote;
Create database vote;
Use vote;

CREATE table  title  (                                                                                                                                                                                                                                                                              
ID INT (6) not NULL auto_increment,
Username varchar is not NULL,
Email varchar not NULL,
           title  varchar () not NULL default ',                                                                                                                                                                                                                                                        
Types tinyint (2) Not NULL default ' 1 ',
Choice text,
           times  datetime not NULL default ' 0000-00-00 00:00:00 ',                                                                                                                                                                                                                                        
Primary KEY (ID)
);

CREATE table  vote  (                                                                                                                                                                                                                                                             
           id  Int (6) not NULL auto_increment,                                                                                                                                                                                                                                     
           titleid  Int (6) Not NULL default ' 0 ',   & nbsp;                                                                                                                                                                                                                                   
           info  Text Not null,                                                                                                                                                                                                                                                           
           vcount  Int (4) Not NULL default ' 0 ',                                                                                                                                                                                                                                    
          primary KEY (ID)                                                                                                                                                                                                                                                           
);
CREATE TABLE Email (
ID INT (6) NOT NULL,
Email varchar NOT NULL,
Primary key (ID, email)
);

Database connection files

The code is as follows Copy Code

<?php
$conn =mysql_connect ("localhost", "phpdb", "phpdb")
Or Die ("Cannot connect to the database server:". mysql_error ());
mysql_select_db ("vote", $conn) or Die ("Cannot select Database:". mysql_error ());

?>

Home 1 2 3 4 last page
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.