Jump to content

PHP Questionnaires Setup and structure


Go to solution Solved by Barand,

Recommended Posts

Hi All,

 

I have a set of question to bring out. I will be need to setup a questionnaires page to let user to fill in. 

The questions is statics, so i don't think i will setup a module to let admin to setup questions/ update questions.

 

So, the thing i need to focus is to create a questionnaires form to get all the inputs and store into the database.

1. Has your manager spoken to you with regards to your resignation?

Yes/No

 

Comment: _______________________________________________________________________________________

 

2a. Have you considered other jobs in ABC Company before making this decision?

 

Yes/No

 

2b. If No, is there any particular area of interest that you would like to consider? (HR can assist with job matches)

 

________________________________________________________________________________________________

 

3. Which factors attracted you to join ABC Company? (check all that apply)

A. Interesting Job                                                     C. Working environment

B. Opportunities for training, advancement, career growth      D. Pay & Benefits

E. Other ________________________________

 

4. What are your reasons for leaving ABC Company? (check all that apply)

A. Change in career                        H. Job Nature, Work load or work hours

I. Quality of supervision

B. Family or personal needs          J. Lack of recognition for work

C. Moving from area                        K. Lack of advancement opportunities

D. To further education         

E. Pay dissatisfaction

F. Benefits dissatisfaction

G. Work environment

 

So if i create a html form and pass all the value to database, im not sure how to store the check box value, have a look to the attachment.

post-179514-0-34527800-1452821573_thumb.png

 

is it not a good practice to store table in a row right? but how could i store a same form in a different row of data? how to store the check box value? i need to create an individual column for them? what is the value should i store when click all the value?

 

 

this form will generate report in future, i still dun have the template currently, but it should be something like average how many people choose the answer.

 

Need Help..~!

Link to comment
https://forums.phpfreaks.com/topic/300341-php-questionnaires-setup-and-structure/
Share on other sites

This is a format that i need to transform into a web form. just i not sure how should i start, which database structure should i use. i need some advice.

1. Has your manager spoken to you with regards to your resignation?
Yes/No
 
Comment: _______________________________________________________________________________________
 
2a. Have you considered other jobs in ABC Company before making this decision?
 
Yes/No
 
2b. If No, is there any particular area of interest that you would like to consider? (HR can assist with job matches)
 
________________________________________________________________________________________________
 
3. Which factors attracted you to join ABC Company? (check all that apply)
A. Interesting Job                                                     C. Working environment
B. Opportunities for training, advancement, career growth      D. Pay & Benefits
E. Other ________________________________
 
4. What are your reasons for leaving ABC Company? (check all that apply)
A. Change in career                        H. Job Nature, Work load or work hours
                                           I. Quality of supervision
B. Family or personal needs                J. Lack of recognition for work
C. Moving from area                        K. Lack of advancement opportunities
D. To further education         
E. Pay dissatisfaction
F. Benefits dissatisfaction
G. Work environment
Edited by FooKelvin

You said something about "static". I assume that you are saying the questions will be static, ie, the same all the time.

 

Setup two tables for this questionnaire alone. Have each question in a column in table 1. Name them as Question1,Question2, Question3... In your second table define the columns as Answer1, Answer2..... and then build your questionnaire form using the cols from table 1. When the user posts the form back you would collect the answers, validate them and ensure that you have answers and then store the results into each column in table2. If you are using checkboxes set the values of them to Yes and No in the html and then simply store the values into the table.

 

Hopefully I understood your question.

Each form that is filled in will correspond to one record in the table, it's not a table by itself.

 

You're not really giving us the information that we need to answer the question you seem to be trying to ask.

 

Is the issue presenting the info, capturing the info or storing the info?

What information are you looking to store (all of it, not just what's in the form) and where is it coming from?

What relationship will this information have to other information that is already stored in your DB?

Will you be generating the questions from data in the database or will it just be hard-coded?

 

It's always better to tell us too much than too little, we're not familiar with your project so we need a certain level of information to provide effective replies.

Setup two tables for this questionnaire alone. Have each question in a column in table 1. Name them as Question1,Question2, Question3... In your second table define the columns as Answer1, Answer2..... and then build your questionnaire form using the cols from table 1. When the user posts the form back you would collect the answers, validate them and ensure that you have answers and then store the results into each column in table2. If you are using checkboxes set the values of them to Yes and No in the html and then simply store the values into the table.

 

What a brilliant example of exactly how db tables should NOT be structured. Relational db tables are not spreadsheets. As soon as you see column names like "Question1, Question2,...,QuestionN",  alarm bells ring. Take a course on data normalization. Store Yes/No values as 1/0.

  • Solution

FooKelvin,

 

I have attached a data model to get you started. You should employ this same approach to your problem your other topic at

http://forums.phpfreaks.com/topic/300461-generate-report-from-check-box-value-comments/?do=findComment&comment=1529890

post-3105-0-16578000-1453031012_thumb.png

Edited by Barand

FooKelvin,

 

I have attached a data model to get you started. You should employ this same approach to your problem your other topic at

http://forums.phpfreaks.com/topic/300461-generate-report-from-check-box-value-comments/?do=findComment&comment=1529890

Hi Barand,

 

Thank You. A bit confuse, the data model also included questionnaire question?

So when i create a html, i can loop the question and the check box option?

Am i right?

While Barand did trash my example, I structured it for the OP's apparently limited understanding.

I wouldn't call it trashing. Barand told the exact truth. It had nothing to do with it being you in particular that posted it. I firmly believe we should not dumb down an answer that is incorrect due to an OP's lack of understanding, but rather provide the correct answer and dumb that down so they can understand the correct way however long it may take them. Better for them to learn may things from doing the right thing than the wrong thing. Compared to us, ALL the OP's have a limited understanding on the posted subject or they wouldn't be posting for help.  :happy-04:

Edited by benanamen

Thank You. A bit confuse, the data model also included questionnaire question?

So when i create a html, i can loop the question and the check box option?

Am i right?

 

 

yes, you should dynamically produce the form using the data from the database. a goal to keep in mind when programming, is to try to write general purpose, data driven, code. by storing the questions (which is just some content as far as the computer is concerned) in a database, the questions can be changed, added, and removed simply by changing the data. the code that retrieves and displays the data will remain the same.

 

also, by storing the questions and any options in a database, this assigns identifiers to that information, that you would use when processing/validating and storing the answers (this is shown in the relationships between the tables in diagram that Barand gave.) this results in simpler code, more easy to secure code, the least amount of data storage requirements, and results in the fastest operating design.

Edited by mac_gyver

May I ask, what is your true goal?

 

* Learn something by doing it yourself?

* Is this your homework assignment or senior project?

* Do you really, really want to re-invent the wheel?

 

Or,

* You need a solution to a business process being developed.

* It's OK to not re-invent the wheel, but rather use someone else's.

 

There are online services and installable applications to take surveys: SurveyMonkey, LimeSurvey, etc.

Edited by bsmither

Hi Barand,

 

i try to understand the data model, so i try to list down what kind of data will store into database.

 

I have listed down the purpose of the table and also the questions i have in the word file above. Please have a look and please correct me if i am wrong.

 

Sorry about you have to redirect to my word file, because i try to paste in here, the align seem to be run.

 

https://onedrive.live.com/redir?resid=B28EE3CD15A16520!1933&authkey=!ANInHOvg10zD6I4&ithint=file%2cdocx

 

 

 

By the way, how if employee select "other" as their choice, where should i store the "other" input?

Edited by FooKelvin
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.