Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Create a league table in mysql & PHP

Explorer ,
Apr 27, 2008 Apr 27, 2008
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
TOPICS
Server side applications
990
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 27, 2008 Apr 27, 2008
LATEST
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
>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines