Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3605342
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:06:40+00:00 2026-05-18T21:06:40+00:00

I have 3 tables in mySQL database. questions_table with these fields: question_id (unique ID

  • 0

I have 3 tables in mySQL database.

questions_table with these fields:

  1. question_id (unique ID for the question)
  2. question_name (the name of the question)
  3. question_positionID (the position of
    the question, I need this because
    the admins are able to change the
    positions of the questions in the
    html form in the frontend. I use
    this to display the questions in the
    form appropriately)

questions_users_relationship_table with these fields:

  1. questions_answers (this is the field
    where it stores what the users
    answered in the frontend form)
  2. user_id (this is used to connect to
    the users table, when loading the
    specific user’s answers to the form)
  3. question_id (this is used to
    reference the question in the
    questions_table)

users_table with these fields:

  1. user_id (unique id)
  2. username (as the name implies, username)
  3. password (as the name implies, password)

So, erm.. The reason why have these 3 tables in the database is because I have to build an admin section on the website which allows the administrators to switch and change the position of the questions in a form. Therefore the reason for the question_positionID field in the questions_table. I have no problem in listing down the questions and its respective answers in the admin section for the administrators to do the position change ( i used ajax drag n drop to update the mysql table on the question_positionID field)..

My problem lies on the frontend html form itself. Because In the database, I only stored the questions and also its answers in its respective tables.. and did not store what type of questions it is (for example: a gender question might use radio buttons for its answers (Male/Female) or maybe address field which has the Country field with answers in the form of a drop down box).. So, in the frontend html form, I am not sure How to list down the questions and its answers for the respective user_id sorted based on the question_positionID and still would properly display the correct form elements (example: questions with dropdown with list the value in the dropdown boxes, questions with answers in radio buttons would be properly checked in the respective radio buttons, and etc etc)..

I believe many people would love to know how to do it.. I not an expert in PHP and mySQL and slowly learning it through examples and online tutorials.. So I would appreciate it if you guys could shed some light on this question of mine..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:06:40+00:00Added an answer on May 18, 2026 at 9:06 pm

    You should add another table with answers:

    Answer

    • answer_id
    • question_id
    • answer_text

    If there are multiple correct answers you will have to add a “is_correct” column to the table as well.

    A simple approach to decide how to display the possible answers in the frontend to add a column allow_multiple_answers to your questions_table and decide whether to use dropdown or radio buttons depending on the number of possible answers.

    $question//the question
    $answers //an array with the possible answers
    $maxAnswersForRadio//maximum numbers of oprions to be displayed with radio buttons 
    if($question['allow_multiple_answers'){
      //use checkboxes to allow mulltiple answers.
      $html = generateCheckboxes($answers);
    }
    else{
       if (count($answers<=$maxAnswersForRadio){
          $html= generateRadioButtons($answers);
       }
       else{
          $html=generateDropDownList($answers);
       }
    } 
    

    This is just a example. The sollution depends on the framework/template engine you use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 5 tables in my Mysql database with t1 with field name like
I have a mysql database with two tables: table1 (id, name, emailid) table2 (id,
I have two tables in my MySQL database, one is a library of all
I have multiple tables in a MySQL database. Lets say they look like this:
I have three tables in a Mysql database - countries, cities and hotels. Their
I have two tables in a MySql database: COUNTRY --------------- id, country_name and CITY
I have multiple tables in a mysql database and I am trying to put
I have 2 tables in my mysql database: CREATE TABLE IF NOT EXISTS `RECIPES`
I have a MySQL database with 60 tables. Most of the tables have primary
In a MySQL database I have two tables linked in a join. One table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.