thinkphp FAQ system Backstage List Show

Source: Internet
Author: User
Requirements are as follows:
Management Center
15) The administrator can enter
16) Can prohibit users to speak
17) Delete the question/answer

The current code is as follows:
function index () {     $goods = D (' question ');     $count = $goods->count ();     $Page = new \think\page ($count, 6);    $list = $goods->table (' ask.question question, ask.answer answer,ask.user user ')->where (' question.id = Answer.tqu and question.userid= user.id ')->field (' question.id as quid,question.text as qutext,question.addtext as Quadd, Question.userid as quuserid,answer.text as antext,answer.addtext as Answeradd, Answer.userid as Anuserid,answer.up, Answer.down,user.name ')->order (' question.id asc ')->limit ($Page->firstrow. ', '. $Page->listrows) Select ();     $show = $Page->show ();     $this->assign (' list ', $list);     Var_dump ($list);     $this->assign (' page ', $show);     $this->display ();


1. Because the question and answer two tables have a corresponding userid. I want a question under which the answer should be answered accordingly. The next question corresponds to the corresponding answer. How this query statement should be written.

2. Or how it should be shown is more effective.


Reply to discussion (solution)

What is the table structure like?

What is the table structure like?




Forget, because question and answer table have UserID, how can all take out the corresponding user name display in the foreground.

It's OK to give a thought to you, Daniel!

15) The administrator can enter
The user table corresponds to a permission field, and when logged in, 1 is the administrator.
16) Can prohibit users to speak
User table corresponds to a User status field with a property of 0 o'clock post prompt permission insufficient
17) Delete the question/answer
Delete corresponding ID

1. Because the question and answer two tables have a corresponding userid. I want a question under which the answer should be answered accordingly. The next question corresponds to the corresponding answer. How this query statement should be written.
Looping nested queries

15) The administrator can enter
The user table corresponds to a permission field, and when logged in, 1 is the administrator.
16) Can prohibit users to speak
User table corresponds to a User status field with a property of 0 o'clock post prompt permission insufficient
17) Delete the question/answer
Delete corresponding ID

1. Because the question and answer two tables have a corresponding userid. I want a question under which the answer should be answered accordingly. The next question corresponds to the corresponding answer. How this query statement should be written.
Looping nested queries

Thanks, I did not say clearly, my top two I have made out, I mainly want to ask is the last one. Could you please be a little more specific?

15) The administrator can enter
The user table corresponds to a permission field, and when logged in, 1 is the administrator.
16) Can prohibit users to speak
User table corresponds to a User status field with a property of 0 o'clock post prompt permission insufficient
17) Delete the question/answer
Delete corresponding ID

1. Because the question and answer two tables have a corresponding userid. I want a question under which the answer should be answered accordingly. The next question corresponds to the corresponding answer. How this query statement should be written.
Looping nested queries



What I want to ask is the last loop nested query


15) The administrator can enter
The user table corresponds to a permission field, and when logged in, 1 is the administrator.
16) Can prohibit users to speak
User table corresponds to a User status field with a property of 0 o'clock post prompt permission insufficient
17) Delete the question/answer
Delete corresponding ID

1. Because the question and answer two tables have a corresponding userid. I want a question under which the answer should be answered accordingly. The next question corresponds to the corresponding answer. How this query statement should be written.
Looping nested queries



What I want to ask is the last loop nested query


$rs 1 = (Query the result set returned by the problem table);
while ($row = mysql_fetch_array ($rs 1))
{
Query the answer for the current question ID, output
}
  • 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.