Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 11-19-2010, 01:14 AM Complex PHP Code???
Banned

Posts: 408
Name: mushget
Trades: 0
I am not sure where to begin with this code or how to go about it. I was wondering if anyone could give me some ideas as to where to start or ideas on how to accomplish this (If you want to help with sample codes I'd love that too, but I'm really looking for ideas on how to accomplish this. From there I can search for how.)

First I already have a system up that requires users to log in in order to access the play page.

When they get to the play page, there will be one question. When they correctly answer this question, it will move them on to the second question. There will be a total of about 50 questions, but when we start, we may only have about 10 - 15 questions ready to go. (I don't think it will be an issue to keep moving forward and adding more questions in once I get everything established.)


Point 1: Ideally what I would like to be able to do is something like this:
Option A: The first person to answer the question correctly gets 100 points. The next person 95. The third person 90. I would like to do this down to 55 points. At this point, anyone who gets it correct will receive 50 points.

Option B: If this is not achievable, perhaps some kind of internal deduction. What I mean by this is the first time Userx logs in and tries to answer the question, he or she would get 100 points if correct on the first try. If it takes Userx 2 tries, they would be awarded 95 points and so on.
I would much rather do the first scoring system than the second one.


Point 2: I want to be able to display the user's total score. Is it better to calculate it in the database (MySQL) or is it possible to do this is through PHP with hidden output fields or something?

Please let me know what the best way to go about this is or if there are any tutorials that I might be able to use or coding I could use I would really appreciate it.
mushget is offline
Reply With Quote
View Public Profile Visit mushget's homepage!
 
 
Register now for full access!
Old 11-19-2010, 02:21 PM Re: Complex PHP Code???
Extreme Talker

Posts: 173
Trades: 0
Point 1:

If you record who has supplied a correct answer to the db, then when the person submits the answer and it is the correct answer simply do a count of the number of correct answers submitted up to that time and then subtract from 100.

IE: If I answer the question and I am the 5th person to answer the question then

total points - (5 points x 5th answer)
=75

You could then keep a score card showing which questions they answered and their score.

In response to the second part of this point, if the person tries to answer the question a second time, they could still be the 5th person but could receive a
penalty for guessing wrong

total points - (5 points x 5th answer) -(5points x (2 answers -1 guess))
=70

Point 2

When the user first enters the game you can query the db for the users points, as you save the users score each time they submit an answer you can record the points.

In general, each time you have to execute a query, it takes time, might only be milliseconds, but time either way and depending on the size of the program, this can add up. Try to keep things in memory.

Last edited by dgkindy; 11-19-2010 at 02:23 PM.. Reason: spelling mistake
dgkindy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Complex PHP Code???
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.69053 seconds with 12 queries