php query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ocptime
Forum Newbie
Posts: 11
Joined: Thu Mar 18, 2004 4:59 am
Location: Trivandrum, Kerala, India

php query

Post 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
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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 ;)
ocptime
Forum Newbie
Posts: 11
Joined: Thu Mar 18, 2004 4:59 am
Location: Trivandrum, Kerala, India

Post 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***************
Post Reply