Forum Moderators: coopster

Message Too Old, No Replies

Select % of group selection

php/mysql

         

mojomartini

10:23 pm on Nov 11, 2007 (gmt 0)

10+ Year Member



Hi,

I have the following sample output:

Name Question Answer
Joe what is .. the answer is ...
Joe what is .. the answer is ..
Marie who is .. the answer is ..
Marie who is .. the answer is...

Basically I am outputting a list of people with their questions and answers. Simple enough. What I can't figure out is how can I generate just a certain percentage of each persons answers. I want to list 25% of each persons answers. I don't want the limit the entire query to 25%.

25 percent of joes
25 percent of Maries
etc..etc...etc...

It would be easy enough if I just wanted to listed 25% of the total number of answers or just 25% of one persons answers but not 25% percent of every persons answers in one big list.

Any clues?

Thanks in advance,

- dan -

Caliber Mengsk

8:02 pm on Nov 13, 2007 (gmt 0)

10+ Year Member



..... This doesn't make much sense as a question to me....
Getting 25% of an answer is just saying that a question is only worth .25 out of 1 point possible...

O-o I guess what I am saying, is that to get 25% of the answer would be the value of the answer (let's say it was 3) multiplied by 25% (.25)

$joe_answer = 3 * .25;

Put into a variable situation

$joe_answer = $answer_value * .25;

This is pretty much basic algebra, unless you are wanting something different then this.

mojomartini

8:26 pm on Nov 13, 2007 (gmt 0)

10+ Year Member



Sorry if I wasn't clear. Let me try this another way.

Let's say I have 5 people who do 100 tasks per day. Each task is recorded into a mySql DB. The next day I want to go ever their work but I don't want to look at all 100 tasks for each of the 5 people but rather only 25% (in this case 25 of each). If I only wanted to look at one persons tasks that day it would be simple. I could easily count the rows (1 task per row) and set a limit variable for 25% of their tasks. The catch here is that I want to everyone's tasks at once. 25% of each person listed all on one page.

Instead of:

Joe Task1 Date1
Joe Task2 Date2
Joe Task3 Date3
Joe Task4 Date4
Mary Task1 Date1
Mary Task2 Date2
Mary Task3 Date3
Mary Task4 Date4

I want:

Joe Task1 Date1
Mary Task1 Date1

and so on....

Hopefully this clears it up a bit...