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
}