Jump to content


Simple trivia


2 replies to this topic

#1 Poke

    Young Padawan

  • Members
  • Pip
  • 3 posts
  • Interests:Krav Maga, photography

Posted 19 January 2007 - 06:32 PM

How I do php code that after user has answered a question wrong, he'll get an hint, and after that he'll answer again to the same question? No pop-ups, those just annoy. This should happen couple times so that I can do 3 point question.

eg. right answer at second trying gets him 2 points. etc.
Basic php perhaps but i'm still a bit lost :(

#2 Mr. Matt

    Moderator

  • P2L Staff
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 20 January 2007 - 12:04 AM

There are two different ways I would go about this, first is using ajax and would be slightly more complex because of that for someone now.

1) You use javascript onClick to pass the value they selected and the question id to an AJAX request which then passses the value onto a php script which then will work out which question it is with the id, and then can see if they are right or wrong depending on the answer passed, and then you can simply return what you want to do.

Or the more basic way is to use $_GET variables to put the answer into a url then you can read it off.

2) When the user clicks the answer the url then becomes ?answer=3 for example, then your script looks for a value to answer, checks it is a valid number by using somthing like is_numeric() and if( $_GET['answer'] > 0 && $_GET['answer'] <= 4 ) {, and then you just check the value of the answer and print out a message depending on what they selected.

Hope this helps

Matt

#3 Poke

    Young Padawan

  • Members
  • Pip
  • 3 posts
  • Interests:Krav Maga, photography

Posted 23 January 2007 - 09:06 AM

Thanks, I'll try the more basic one first.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users