SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A doubt on Online Quiz in PHP

    I just wanted to develop a web application, an online quiz, in which i need to fetch questions only once & display one at a time as the user clicks the NEXT button. But, in php ,i guess it is difficult to have the questions(data) stored & use it on the event basis(button click)(since its a mere script invocation). Whereas , in asp.net it is easily done, since the data fetched can be stored till the user ends appln. So can u suggest some ways to do it in php......? or asp.net is the only go...?

  2. #2
    SitePoint Zealot Mattinblack's Avatar
    Join Date
    May 2009
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by skpraveen View Post
    I just wanted to develop a web application, an online quiz, in which i need to fetch questions only once & display one at a time as the user clicks the NEXT button. But, in php ,i guess it is difficult to have the questions(data) stored & use it on the event basis(button click)(since its a mere script invocation). Whereas , in asp.net it is easily done, since the data fetched can be stored till the user ends appln. So can u suggest some ways to do it in php......? or asp.net is the only go...?
    No you can use Ajax - which is a mix of javascript and PHP. Its easier than you think - look at this simple Ajax tutorial. All that happens is that the javascript handles the button press and requests your next question from a php script, this then passes the info to javascript and javascript displays it. the Javascript is pretty much all cut n paste from the demo I think.

    Alternatively you can just refresh the whole page with a new question in PHP alone.

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    You do not even need JavaScript, just have to utilize sessions.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    SitePoint Evangelist ferrari_chris's Avatar
    Join Date
    Mar 2008
    Location
    NP, New Zealand
    Posts
    576
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've built a similar (actually, sounds identical) quiz in the past and when the quiz loaded I would do all of the fetching then.

    Storing the questions/answers and the user's responses in the session.

    At the end of the quiz the reposnses would be submitted back to the db.

  5. #5
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for ur reply .

    Can u explain still more about doin this with ajax, bcoz i dont want to use DB quesries each time to access the Db & get each question. I guess using ajax will involve such DB queries..can u help me more in this way.

  6. #6
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks ferrari chris.
    But i heard that sessions are also almost like database files stored in the server. so

    1.Is it not same as accessing the database, in terms of load..?

    2. Is it possible to store questions& answers (such a huge data) into sessions..? is there any size limitations..?
    kindly help me.

  7. #7
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks logic earth
    But i heard that sessions are also almost like database files stored in the server. so

    1.Is it not same as accessing the database, in terms of load..?

    2. Is it possible to store questions& answers (such a huge data) into sessions..? is there any size limitations..?
    kindly help me.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •