New to PHP got a quiz. Have a input form for answers that goes to a mysql table in db 15 Questions/15Answers. And also within the db a questions table an ID field that goes to 15 and a correct answer field.
Questions Table:
- ID - int 11 /PK / Not NULL
- question - text / Not NULL
- rightanswer - text / Not NULL
Answer Table:
- ID - int 11 / PK / Not NULL
- inputanswer1 - varchar 255 / Not NULL
- inputanswer2 - varchar 255 / Not NULL
- inputanswer3 - varchar 255 / Not NULL
I want to know using this method of checking from the questions table the correct answer which I’ve done below but issue I’m having is than matching that with another table where the input answers are stored.
Question is what’s the operator used to get saying ‘equal to’ something else and seeing if they match. And it’s this all in 1 select query.
Questions Table
SELECT fieldname (rightanswer) FROM tablename (Questions) WHERE ID = 1;
SELECT fieldname FROM tablename WHERE Id = 2;
This above code is working and doing the first part I want it to do which is selecting the “rightanswer” from “Questions” table with the first question ID of “1” now need help with second part of matching/comparing that to where the answers are inputted which is in “Answers” table with starting with “inputanswer1”
Looking for does the “rightanswer” from “Questions” table match “inputanswer1” from “Answers” table.
??? Answers Table
SELECT fieldname FROM tablename;