Learn to do online surveys with me (i)

Source: Internet
Author: User
Tags functions modify connect table name administrator password
Write online in front
About the online survey you must not be unfamiliar with it, give a question and several answers, so that users
Fill in, and then save the results to the database, automatic statistics, and finally give a statistical diagram. This
Period of learning to do with me to do an online survey system.

First, the function design
This simple system also needs to do functional design? Some people may feel strange, but then again
No matter how kind of system, the first function design can always have a comparative understanding of the system. Let us
Take a look at the function of the online survey. The basic function has been said, is to give a question and several
An answer, then a statistic, and finally a graph. On this basis, we can consider a survey to add
A period of time (validity), in this time period of investigation is valid, after this period of time will automatically knot
Bundle of this investigation. In addition, we can specify that a user can submit only one answer at a time. If you want to limit
Make more, you can specify an IP can only submit one answer, however, this may be a person in the Internet café
Only one was submitted. Some of the problems in the survey may be a single choice, and some may be multiple-choice
Problem. Finally, the statistics chart, in the statistical map to give the answer, the number of votes for each answer, and to
Shows the percentage of votes per answer. The general use of horizontal map on it, but also relatively easy to achieve,
Of course, if you want to change to vertical, you can also.
Now based on the above summary of the online survey functions are as follows:
1, the data is kept in Access 2000 database;
2. One visit per user can vote once
3, give the statistics of each survey, with a statistical map to show
4, each investigation has an expiration date, automatically end after expiration. The completed survey can only view the results.
5, the administrator can increase the investigation, modify the investigation of the answer (add, modify, delete, modify type).
6. For the completed investigation, the administrator can only delete the investigation, but not the answer.
7, only one administrator (single user)

Second, database design
Now to design the database, according to functional requirements, at least three tables, one is the administrator table, the second is
Questionnaire, third is the survey results table. The database file name is Survey.mdb can be changed to. asp if
, please make the corresponding modification in the ASP program.

Table A, Administrator table table name: Manage
-----------------------------------------------------------------
Field type length description
-----------------------------------------------------------------
MANAGE_ID AutoNumber-No use here, future expansion
Manage_username Text 15 Administrator user name
Manage_password Text 15 Administrator password
-----------------------------------------------------------------

Create the Manage table and add a new record, fill in your admin username and password, and fill in the Xmxoxo

Table II, Questionnaire table name: survey
-----------------------------------------------------------------
Field type length description
-----------------------------------------------------------------
SURVEY_ID automatic numbering-increments, primary keys, indexed no Duplicates
Survey_question Text 255 Survey questions
Survey_type-Type, no: Radio is: multiple selection
Survey_stime Date-long date, start time
Survey_etime Date-long date, end time
-----------------------------------------------------------------

Table III, survey end table name: Survey_vote
-----------------------------------------------------------------
Field type length description
-----------------------------------------------------------------
Vote_no automatic numbering-increments, primary keys, indexed no Duplicates
vote_id long integral type-index has duplicate, decimal digit 0
Vote_answer Text 100 Survey answers
Vote_count Long integer-Number of votes
-----------------------------------------------------------------

Where the ID field of the Survey_vote table and the survey table has a many-to-many relationship. It doesn't have to be a relationship,
But building relationships can make ideas clearer.

Iii. include documents
Here is not a lot of functions to use, mainly to the database operation, if you want to prevent the input of the
HTML and other code, directly with Server.HTMLEncode processing on it, so do not need a dedicated
function to handle. We can use the previous "Follow Me" series "Follow me to learn to do tree menu" in the inclusion file.
Shared function file, filename: inc.asp
<%
'*******************************************************************
' Common Database ASP functions
'*******************************************************************
' Database constants
Databasename= "Survey.mdb" database name, if renamed, modify the line here
'*******************************************************************
' Open the Database
Sub Opendb (Connect)
Set Connect=server. CreateObject ("Adodb.connection")
Connect. connectionstring= "Driver={microsoft Access DRIVER (*.mdb)}; Dbq= "&_
Server. MapPath (DatabaseName)
Connect. Open strconn
End Sub
'*******************************************************************
' Close the database
Sub Closedb (Connect)
Connect.close
Set connect=nothing
End Sub
'*******************************************************************
' Open a single table read
Sub OpenTable (connect,tbname,myrs)
Set Myrs=server.createobject ("Adodb.recordset")
Rssql= "SELECT * from" & Tbname
Myrs.open rssql,connect,1,1
End Sub
'*******************************************************************
' Close temporary table
Sub CloseTable (RS)
Rs.close
Set rs=nothing
End Sub
'*******************************************************************
' Querying the Database
Sub Searchtable (CONNECT,SQL,RS)
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open sql,connect,1,1
End Sub

'*******************************************************************
' Query and change the database
Sub Changetable (CONNECT,SQL,RS)
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open sql,connect,1,3
End Sub

'*******************************************************************
' Display information for debugging
Sub W (msg)
Response.Write msg
End Sub

'***************************************************



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.