locked
Displaying and inserting Quiz Items RRS feed

  • Question

  • Hello Everyone. 

    This is my first post in here - I hope i've laid it the correct place :) 

    I am really new to Visusal Studio / C# / ASP. 

    But currently i am doing a little test project, to make a website, with a quiz, where users can go in and fill out information.

    I've made the backend, to insert new questions/Answers etc. 

    My databases is as following: 

    Questions:  ( the tabel for the questions name) 
    - Questionsid
    - QuestionsName

    QuizAnswers ( the tabel for all the differently answers, to each question, that a Administrator create) )
    - QuizAnswerID
    - QuestionsID
    - QuizAnswer
    - Correct (True/False) 

    But my big problem is this. 

    I am used to Dreamweaver and php.

    I need to show all the Questions from Questions tabel, and include the answers below the questions. 
    The key to combine the 2 tabels are the: "QuestionsID". 
    I've searched all of google, with no real results, and right now i am lost... 

    So my problem is: 
    1. How do i display the questions and the answers, and at the same time to combine the 2 tabels, with the QuestionsId. 
    2. How do i repeat that, so that i can repeat the region, until the questions tabel is empty, like if i want to show 10 questions, and all the answers to each question. 

    Ex: 
    What color is bla bla: (Question name is from the Question tabel) 
    1 - Red (The answer is from the Answers tabel) 
    2- Blue (The answer is from the Answers tabel) 


    Regards
    Matias
    Friday, May 10, 2013 12:45 AM

Answers

  • You need ot use a SQL "JOIN" query to combine the two tables.  You can google the web for "SQL JOIN" and find lot so results.  I would setup your table of answers to each answer is a different field (column) ot the answer table in the database so all the answers to a question is on a single row.  this will make you code that processes the query simplier bacuase your don't have to combine rows in the response to the query. 

    jdweng

    Friday, May 10, 2013 6:51 AM