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 8612735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:42:05+00:00 2026-06-12T04:42:05+00:00

this is my database design for a ques n ans page. A user can

  • 0

this is my database design for a ques n ans page.
A user can ask as many questions, receive as many answers to a single question.
ie. one question and many answers.

All i want to know is mysql query that’ll be required for fetching the answers for a particular database. Also the php code that’ll be involved in sending and thereby retrieving the results.

db design:

create table user (
 name varchar(14) not null.
 id int(11) auto_increment;

CREATE TABLE questions (
 question_id int(11) NOT NULL AUTO_INCREMENT,
 user_id int(11) references user(id),
title varchar(255),
content text, 
PRIMARY KEY (question_id);

CREATE TABLE answers (
answer_id int(11) NOT NULL AUTO_INCREMENT,
question_id int(11) REFERENCES questions(question_id),
content text,
PRIMARY KEY (answer_id);
  • 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-06-12T04:42:06+00:00Added an answer on June 12, 2026 at 4:42 am

    If you already know the ID for the particular question, then all you need to do is select all the records in answers with that question_id. If you’re selecting based on some other attribute of the question, then you’d select that question from questions with LEFT JOIN answers on questions.question_id = answers.question_id in order to get all the relevant answers.

    As for PHP code, read up on mysqli or PDO. This should be a textbook case of running a query and then fetching the results. Check out example 1 on this page for how to create a DB connection and example 1 on this page for a very simple query example. But note that if you’re searching on a user-provided string, a simple query like that creates huge security holes! You should use the prepare() function instead.

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

Sidebar

Related Questions

This is more a question of practical database design. I've designed smaller databases before,
This is a general question about mongodb database design, but the reason for my
I'm working on a database design for an e-commerce web application. For this question
How would I draw up this design in a database? A product can be
This is a database design question. I want to build an invoice web application,
As I understand from this database design question , you should use nullable fields
As this question is sure to reveal, I'm relatively new to database design. Please
This question comes up after reading a comment in this question: Database Design When
This is a generic database design question - What are the benefits of using
The question is how database design should I apply for this situation: main 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.