FooKelvin Posted January 15, 2016 Share Posted January 15, 2016 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. 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..~! Quote Link to comment https://forums.phpfreaks.com/topic/300341-php-questionnaires-setup-and-structure/ Share on other sites More sharing options...
BuildMyWeb Posted January 15, 2016 Share Posted January 15, 2016 i don't understand what youre saying you want to do or, really, what your question even is. you should paste your code attempt here, tell us what youre trying to achieve, and where its going wrong. Quote Link to comment https://forums.phpfreaks.com/topic/300341-php-questionnaires-setup-and-structure/#findComment-1529686 Share on other sites More sharing options...
FooKelvin Posted January 15, 2016 Author Share Posted January 15, 2016 (edited) 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 January 15, 2016 by FooKelvin Quote Link to comment https://forums.phpfreaks.com/topic/300341-php-questionnaires-setup-and-structure/#findComment-1529695 Share on other sites More sharing options...
ginerjm Posted January 15, 2016 Share Posted January 15, 2016 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. Quote Link to comment https://forums.phpfreaks.com/topic/300341-php-questionnaires-setup-and-structure/#findComment-1529768 Share on other sites More sharing options...
Muddy_Funster Posted January 15, 2016 Share Posted January 15, 2016 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. Quote Link to comment https://forums.phpfreaks.com/topic/300341-php-questionnaires-setup-and-structure/#findComment-1529772 Share on other sites More sharing options...
Barand Posted January 17, 2016 Share Posted January 17, 2016 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. Quote Link to comment https://forums.phpfreaks.com/topic/300341-php-questionnaires-setup-and-structure/#findComment-1529899 Share on other sites More sharing options...
Solution Barand Posted January 17, 2016 Solution Share Posted January 17, 2016 (edited) 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 Edited January 17, 2016 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/300341-php-questionnaires-setup-and-structure/#findComment-1529902 Share on other sites More sharing options...
ginerjm Posted January 17, 2016 Share Posted January 17, 2016 While Barand did trash my example, I structured it for the OP's apparently limited understanding. A firs-time solution that hopefully he would learn many things from and then learn how to properly structure a db. Quote Link to comment https://forums.phpfreaks.com/topic/300341-php-questionnaires-setup-and-structure/#findComment-1529908 Share on other sites More sharing options...
FooKelvin Posted January 17, 2016 Author Share Posted January 17, 2016 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? Quote Link to comment https://forums.phpfreaks.com/topic/300341-php-questionnaires-setup-and-structure/#findComment-1529911 Share on other sites More sharing options...
benanamen Posted January 17, 2016 Share Posted January 17, 2016 (edited) 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. Edited January 17, 2016 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/300341-php-questionnaires-setup-and-structure/#findComment-1529915 Share on other sites More sharing options...
mac_gyver Posted January 17, 2016 Share Posted January 17, 2016 (edited) 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 January 17, 2016 by mac_gyver Quote Link to comment https://forums.phpfreaks.com/topic/300341-php-questionnaires-setup-and-structure/#findComment-1529919 Share on other sites More sharing options...
bsmither Posted January 18, 2016 Share Posted January 18, 2016 (edited) 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 January 18, 2016 by bsmither Quote Link to comment https://forums.phpfreaks.com/topic/300341-php-questionnaires-setup-and-structure/#findComment-1529941 Share on other sites More sharing options...
FooKelvin Posted January 18, 2016 Author Share Posted January 18, 2016 (edited) 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 January 18, 2016 by FooKelvin Quote Link to comment https://forums.phpfreaks.com/topic/300341-php-questionnaires-setup-and-structure/#findComment-1529949 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.