Jump to content

Java working with PHP


Asheeown

Recommended Posts

Okay, I'm making a simple online quiz, the PHP part gets 35 random questions and posts them on the page.

All questions that are pulled from the DB are stored in an array with their ID (Example: $Questions[1] = "16", So questions 1's ID is 16)

All the IDs of the correct answers are also stored in an array with their ID (Example: $Answers[1] = "20", So the answer to question 1 is the answer with the ID of 20)

 

Now, before I go too far with the PHP and make it seem like I'm asking a question about that I need to parse the user input and display results without reloading the page.

 

I'm not looking for someone to do it for me, I just need an idea of where to start with this.  I need to pass the two arrays to javascript, and for each one I need to check it against the radio buttons the user filled out to see if they got the right answer, if not highlight theirs with red and print "Incorrect answer" next to it and print "Correct answer" next to the correct one always.

 

The radio buttons hold the question ID in the name directive and the answer ID in the value directive.

 

Any help would be great, I don't know where to begin.

Link to comment
Share on other sites

I was trying to avoid Ajax this time, not that I don't think it would work in this situation it's just it seems that all I really need to do is pass the arrays and then get a nice foreach statement in there and it would work perfectly, the rest, like highlighting answers and giving results is a piece of cake.

Link to comment
Share on other sites

I was trying to avoid Ajax this time, not that I don't think it would work in this situation it's just it seems that all I really need to do is pass the arrays and then get a nice foreach statement in there and it would work perfectly, the rest, like highlighting answers and giving results is a piece of cake.

Oh well if you want to pass the questions and answers as 2 arrays to JavaScript, then you don't need AJAX, but then the answers would be available for anyone viewing the source.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.