473,396 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

creating a league table from a database

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 5650
harshmaul
490 Expert 256MB
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
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
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) ------ ...
3
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....
2
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
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...
6
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, ...
6
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...
2
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",...
4
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 ...
10
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.