quitz application

I’m trying to create a quitz.In the table questions I have the fields id, question and answers.
Table answers I have id, questionsid (to focus the answers to the question) and the answers (right ones and wrong ones).

I’ll try to collect the answers in a gridedit page where I show questions row by row and the answers are chechboxes to click.My problem is that I can’t get the question rows match the right answers.
I try to use lookuptable to get the right answers to each row without any luck. Either all the answers are shown on all pages, or one question’s answers on each page or no answers at all.Any good and simple ideas?

perttiketola wrote:
I try to use lookuptable to get the right answers to each row without any luck.Please post your code or your customization that you did for more discussion.

TABLE QUESTIONS"id" “question” “answers”
“11” “Question 1” NULL
“12” “Question 2” NULLTABLE ANSWERS"id" “qid” “answer”
“11” “11” “q1 answer 1”
“12” “11” “q1 answer 2”
“13” “12” “q2 answer 1”
“14” “12” “q2 answer 2”
“15” “11” "q1 answer 3"TABLE QUIZ a custom view or VIEW containong data from questions table


  • is used to collect users’s answers in gridedit mode

“id” “question” “answers”
“11” “Question 1” NULL
“12” “Question 2” NULL

  • field answers
  • lookuptable,
    tablename = answers,
    link field = answer,
    display field = answer,
    filter = pkfilter(CurrentPage()->id->CurrentValue)

GLOBAL FUNCTIONfunction pkfilter($qid) {// echo shows $qid to be 11, 12 and empty

if ($qid <> “”) {
$ret = “qid = $qid”;
} else {
$ret = “”;
}
return $ret;
} // functionIf $ret is forced to 11 in the pkfilter: $ret = “qid = 11”; it runs like it shouldquestion | answersQuestion 1 | q1 answer 1 q1 answer 2 q1 answer 3
Question 2 | q1 answer 1 q1 answer 2 q1 answer 3meaning that I’ll get all the answers belonging to the question 1. OK this was just a test.The debug is:0.002909: (mysqli): SET NAMES ‘utf8’. Error: (0)
0.006747: (mysqli): SELECT COUNT(*) FROM quiz. Error: (0)
0.007551: (mysqli): SELECT * FROM quiz LIMIT 0, 20. Error: (0)0.008499: (mysqli): SELECT answer, answer AS DispFld, ‘’ AS Disp2Fld, ‘’ AS Disp3Fld, ‘’ AS Disp4Fld, ‘’ AS SelectFilterFld, ‘’ AS SelectFilterFld2, ‘’ AS SelectFilterFld3, ‘’ AS SelectFilterFld4 FROM answers WHERE (qid = 11) AND (0=1). Error: (0)0.009162: (mysqli): SELECT answer, answer AS DispFld, ‘’ AS Disp2Fld, ‘’ AS Disp3Fld, ‘’ AS Disp4Fld, ‘’ AS SelectFilterFld, ‘’ AS SelectFilterFld2, ‘’ AS SelectFilterFld3, ‘’ AS SelectFilterFld4 FROM answers WHERE (qid = 11) AND (0=1). Error: (0)0.009777: (mysqli): SELECT answer, answer AS DispFld, ‘’ AS Disp2Fld, ‘’ AS Disp3Fld, ‘’ AS Disp4Fld, ‘’ AS SelectFilterFld, ‘’ AS SelectFilterFld2, ‘’ AS SelectFilterFld3, ‘’ AS SelectFilterFld4 FROM answers WHERE (qid = 11) AND (0=1). Error: (0)But what I would like see are the answers to the questions 1 and questions 2 on their own rows.
So the original row $ret = “qid = $qid”; in the pkfilter() and no forse to id=11.And the page result is that every question row shows all the answersquestion | answersQuestion 1 | q1 answer 1, q1 answer 2, q2 answer 1,q2 answer 2,q1 answer 3
Question 2 | q1 answer 1, q1 answer 2,q2 answer 1, q2 answer 2,q1 answer 3

BUT debug shows that there should be different answers to each questions.0.003016: (mysqli): SET NAMES ‘utf8’. Error: (0)0.006296: (mysqli): SELECT COUNT(*) FROM q2. Error: (0)0.006951: (mysqli): SELECT * FROM q2 LIMIT 0, 20. Error: (0)0.007871: (mysqli): SELECT answer, answer AS DispFld, ‘’ AS Disp2Fld, ‘’ AS Disp3Fld, ‘’ AS Disp4Fld, ‘’ AS SelectFilterFld, ‘’ AS SelectFilterFld2, ‘’ AS SelectFilterFld3, ‘’ AS SelectFilterFld4 FROM answers WHERE (qid = 11) AND (0=1). Error: (0)0.008754: (mysqli): SELECT answer, answer AS DispFld, ‘’ AS Disp2Fld, ‘’ AS Disp3Fld, ‘’ AS Disp4Fld, ‘’ AS SelectFilterFld, ‘’ AS SelectFilterFld2, ‘’ AS SelectFilterFld3, ‘’ AS SelectFilterFld4 FROM answers WHERE (qid = 12) AND (0=1). Error: (0)0.009646: (mysqli): SELECT answer, answer AS DispFld, ‘’ AS Disp2Fld, ‘’ AS Disp3Fld, ‘’ AS Disp4Fld, ‘’ AS SelectFilterFld, ‘’ AS SelectFilterFld2, ‘’ AS SelectFilterFld3, ‘’ AS SelectFilterFld4 FROM answers WHERE 0=1. Error: (0)But there is the " AND (0=1)“. If I test the sql without it (on a separate sql tool) I’ll get correct list for both qid = 11 (or 12). Is that reason for the problem or somewhere else. Can I modify the SQL to delete the " AND (0=1)”?

Or is there other solutions?My Phpmaker version is 2018 (14.0.6)