473,587 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

creating a league table from a database

40 New Member
I’m looking for a little help and guidance on creating a league table from entries in a database, because of other requirements it is not possible to update the entry for the person in the database. So there is going to be multiple rows for the same person I would then like to add up the points for that person. Around ten people will be apart of the league and the total number of rows will be no more than one hundred so I don’t think there will be to much overhead on the database plus the site is never going to be main stream just the 10 members will be visiting.

I was thinking about doing a select statement and then doing a while loop going through all the records, then a for statement for each row that equals the name adding the points together.

Is it a case of writing out the results such as:

[PHP]$name1 = Tom
$name2 = Ste [/PHP]

Then doing something like:

[PHP]$i = 1
foreach ($row[‘name’] = $name{$i}; $i++)
{
‘add up points here
}[/PHP]

Thank you for your help

Tom
Jan 30 '08 #1
2 5665
harshmaul
490 Recognized Expert Contributor
Hi,
Firstyl you will need to consider a different table structure. Are you a football (soccer) person? Thats the example i'm going to try and use to help me explain.

You have ONE table (tblTeams), and that table contains a list of all of the teams that are going to play with a structure like this,

Expand|Select|Wrap|Line Numbers
  1. --tblTeams
  2. TeamID
  3. TeamName
everytime a team wins they get three points so you will need to count this up, so you have another table (tblPoints) with a structure like this,

Expand|Select|Wrap|Line Numbers
  1. --tblPoints
  2. PointID
  3. TeamID
  4. Points
So now each time a team wins, insert a new record into tblPoints with the TeamID of the team and the number of points the team was awarded.

Now when you want to display the league table you would run a query somthing like this....

Expand|Select|Wrap|Line Numbers
  1. SELECT tblPoints.TeamID as TeamIDA, SUM(Points) FROM tblPoints
  2. inner join tblTeams on tblPoints.TeamID = tblTeams.TeamIS
  3. GROUP BY TeamIDA
This should sort you out
Jan 30 '08 #2
tommurray
40 New Member
Thank you for your help, I was hoping to see a method that would be able use the data that is currently stored in the table. Reducing the need to add further SQL scripts to the original part of my code, so I think the easiest approach would be to create another table and update the points.

But thank you for the SQL script it will come in handy and I was not aware that approach.

Thank you

Tom
Jan 30 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2790
by: Richard Williamson | last post by:
Hi all, I have a problem designing the tables for a leasgue table calculating database. The current structure is this (irrelavent bits omitted) tabTeam(TeamID, TeamName) ------ tabPlayer(PlayerID, TeamID) --------
3
5237
by: kylei | last post by:
Would MS Access be able to run a Fantasy League for about a 100 players while allowing people to make changes via the web? It would be run salary cap style with the rosters locking every Monday. It would have to be able to keep the stats for a player that was dropped and all that kind of stuff.
2
3909
by: edwgib2002 | last post by:
Does anyone have any information related to a scheduling algorithm that can be written in VBA and used in an access database to create balanced team schedules for a league?
3
1892
by: stephenf33 | last post by:
Hi All I was wondering if anyone knew how to or has developed an access database that could record exam scores and then copy information onto another form as a league table, showing the highest results Any help would be greatly appriciated Many Thanks Stephen
6
2056
by: hinksta | last post by:
I'm trying to build a football leage table taking it's content from a results database, CREATE TABLE conference ( id int NOT NULL auto_increment primary key, season VARCHAR(50) NOT NULL, gamedate DATE NOT NULL, hometeam VARCHAR(50) NOT NULL, homescore VARCHAR(30) NOT NULL, awayscore VARCHAR(50) NOT NULL, awayteam VARCHAR(30) NOT...
6
2291
by: mtgriffiths86 | last post by:
Where do i begin...well I am attempting to build a league management website that will automatically work out league tables, fixtures and results. The first problem that i have is this: To automaticaaly work out the fixtures i plan on having the highest point scorers from the previous month to play against the 2nd highest point scores and...
2
17891
by: minus | last post by:
public class Test { public static void main (String arg) { // "012345678910" alignment guide String results = {"AR 4 BR 5", "CR 0 DR 1", "AR 10 CR 9", "BR 3 DR 1", "AR 0 DR 2", ...
4
7657
by: minus | last post by:
import java.util.Arrays; import java.util.Collections; public class Test { public static void main (String arg) { // "012345678910" alignment guide String results = { "AR 4 BR 5", "CR 0 DR 1", "AR 10 CR 9",
10
2492
by: CoachDave48 | last post by:
All, I am learning PHP and MySQL on the fly so if my question shows I don't know what I am doing, it's because I don't. Any help is appreciated. I have set up a registration database for my kids little league (baseball). I can collect data (name, age, address etc) in the form and post it to the db. I can recall the data edit and repost. ...
0
7920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5394
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.