How do I rank students in a class by exam mark attained?

My query below is arranging students in a class by order of highest mark perfectly well, my problem however is how to have their class position displayed? What’s the php code I should write?

SELECT *
FROM f_teachers, summary1
WHERE f_teachers.year = summary1.yr AND f_teachers.class= summary1.clas AND t_id=%s
ORDER BY mark ASC;

i looked at this question a while ago, saw that you were asking for php code, and noted to myself that you were astute enough to realize that php is where ranking should be done on an ordered dataset

and as i don’t do php, i just passed it by

now i’ve noticed this thread has been moved to the databases forum, which i find rather curious

ranking should be done with php, assuming that the query indeed returns more than one student

(you really didn’t give very much information on what t_id=%s is for, but i’m gonna guess it’s teacher)

despair not, though, because some of our database guys do indeed know php

when is your homework assignment due?

:slight_smile:

p.s. the move of this new thread from php to databases forum is ~especially~ curious because posting in the php forum was exactly what i recommended you do in this thread

That would be my doing Rudy.

If, as you say, this sorting should be done in the application I’ll move it back. :slight_smile:

thanks anthony

now all we gotta do is wait for a php guy to notice the thread

we’ve had threads like this before, the solution will be really trivial, i just don’t do php myself or there wouldn’t have been all this kafuffle