I have a table named: 'paper' (question_bank)
id | exam_id | question
1 | 1 | What will be 35*9?
2 | 1 | What will be 5-9?
3 | 1 | A + B
4 | 1 | What is a circle?
5 | 1 | If we have four corners with equal height and width, then which shape is that?
6 | 1 | What is Maths?
7 | 1 | What is a triangle?
21 | 1 | what is Nikhil surname?
22 | 2 | Last name of Bhavesh is
23 | 2 | Last name of Harsh is
27 | 3 | What is Maths?
28 | 3 | What is a triangle?
30 | 3 | Last name of Harsh is
I have a php page where i have to add questions in exam_id '3' from table 'paper'. my query to insert question is as below:
INSERT INTO paper (question exam_id) SELECT question, '3' FROM paper WHERE id = '2'
OR
INSERT INTO paper (question exam_id) SELECT question, '3' FROM paper WHERE id = '1'
OR
I can also add a new question, so the query is:
INSERT INTO paper (question, exam_id) VALUES ('blah blah blah', '3')
It depends on question i select OR any new question i add.
Now, when i want to add more questions to exam_id '3' from table 'paper', it shows all the questions. My select query is as below:
SELECT * FROM paper WHERE exam_id != '3'
It shows all questions, but for instance i already added id = '23', so i dont want that question to display when i am adding more questions. Please help me with my select query. Let me know if i miss anything! Thanks in advance!
Okay I got it.....
All I needed to do was, to fire the query again for not to repeat the questions that are selected previously....
SELECT * FROM paper WHERE question = '$row['question']' AND exam_id = '3'
if($select)
{
************************* SHOW RESULT *********************
}
I'm not sure if I understood you correctly but you can make a list with the ids of the questions that you don't want to see.
For example: exclude ids
23, 24, 25
SELECT * FROM paper WHERE exam_id != 3 AND id NOT IN (23, 24, 25)