Page 1 of 1

php query

Posted: Sat Mar 20, 2004 12:49 am
by ocptime
my result is this

testId studentId marks result title name
1 96 5 Passed Test Your IQ? Paul
1 96 6 Passed Test Your IQ? Paul
1 78 0 Failed Test Your IQ? Mark
1 96 1 Failed Test Your IQ? Paul

How can i change the RS to:

how many times each student appeared 4 each test
eg Paul takes Test Your IQ? 3 times mark 1 time

pls help

Posted: Sat Mar 20, 2004 1:12 am
by markl999
Far too little information.
Are you using mysql , pgsql, flat file?
By 'appeared 4 each test' i presume you mean 'appeared for each test'?
By 'RS' do you mean 'result' ?
Do you have some existing code you can show us ?
What have you tried so far ?
Did you read http://www.catb.org/~esr/faqs/smart-que ... html#intro :o

Not trying to be anal or anything, but a more detailed initial question usually saves a load of posts trying to get to the actual problem/solution ;)

Posted: Sat Mar 20, 2004 1:17 am
by ocptime
thanks mark for pointing to my too little info
ifound out that by using GROUP BY and COUNT we can still manipulate the initial resultset to get to the desired result

$sql="SELECT count(r.testId), r.studentId, t.title, u.name FROM qb_test_report as r, qb_test as t, user as u
WHERE r.status='Completed' AND t.testId=r.testId AND u.id=r.studentId
GROUP BY r.testId, r.studentId";


****************Thanx MAte***************