Skip to main content
Participant
April 27, 2008
Question

Create a league table in mysql & PHP

  • April 27, 2008
  • 1 reply
  • 991 views
hi, was wondering if anyone could help?;

I want to calculate a classes total praise and then compare it to other classes totals to create a league table of scores.

Explanation of tables and feilds:

I have two table, student and teacher.

student(Student_id, name, year_group, form, praise)
teacher(teacher_id, name, form, total_praise)

students get given 'praise' this is stored in the database as an int.

each student is grouped in to a 'form' and each teacher has a form full of students.

i want to be able to calculate the total praise for a form and then compare that total to all the other forms totals and create a league table.

What is working:
i can total the praise for a specific form.

what i can not do:
at the minute the total_praise in the teachers table is empty.... I want the total praise for the class to be added here automatically. so i can then just compare this for the league table.

Any help would be much appreciated,

Thanks, Gavin
This topic is closed to new replies. Start a new post to keep the conversation going.

1 reply

Inspiring
April 27, 2008
godonholiday wrote:
> hi, was wondering if anyone could help?;
>
> I want to calculate a classes total praise and then compare it to other
> classes totals to create a league table of scores.
>
> Explanation of tables and feilds:
>
> I have two table, student and teacher.
>
> student(Student_id, name, year_group, form, praise)
> teacher(teacher_id, name, form, total_praise)
>
> students get given 'praise' this is stored in the database as an int.
>
> each student is grouped in to a 'form' and each teacher has a form full of
> students.
>
> i want to be able to calculate the total praise for a form and then compare
> that total to all the other forms totals and create a league table.
>
> What is working:
> i can total the praise for a specific form.

SELECT SUM(praise) from student WHERE form="form name"

Look at mysql "GROUP by" clause to make more sophisticated selections.
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html
>
> what i can not do:
> at the minute the total_praise in the teachers table is empty.... I want the
> total praise for the class to be added here automatically. so i can then just
> compare this for the league table.

Whether you can do this depends on which version of mysql you are using.
Mick
>
> Any help would be much appreciated,
>
> Thanks, Gavin
>