php - Show data from database based on user input -


i'm creating way "teacher" make exam , "student" can take exam.

first off, possible teacher make new questions, using query:

insert questions (question, type) values ('$question', '$type') 

in database, set questions have question_id auto incremented after each entry. on separate page, can pick questions add exam. just:

select * questions 

then there checkbox them check questions add use query:

insert exams (question_id) values ('$question_id') 

the table exams has auto incremented exam_id. display questions teacher picked, don't know type should store question_id in exams (right int) can loop through them.

ie. teacher picks questions 1,2,4,10 , query getting question

select question questions question_id='1,2,4,10' 

assuming getting question id post or get, try this:

$selected = implode(',', $_request['selectedquestionids']);  select question questions         question_id in ($selected)        group question_id; 

hope may help.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -