473,320 Members | 1,916 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,320 software developers and data experts.

League Table

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 3rd v 4th and so on.

Im not sure how to take the data from my database and input the information into the correct place so that the team names show correctly each week.

Can anybody please help me?

Thanks in advance

Matthew
Jan 18 '08 #1
6 2265
dlite922
1,584 Expert 1GB
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 3rd v 4th and so on.

Im not sure how to take the data from my database and input the information into the correct place so that the team names show correctly each week.

Can anybody please help me?

Thanks in advance

Matthew
Could you explain more on how the process works more in detail.

Do you have a match schedule of days already?

The team that ranks the lowest will be dropped out?

Say we have 10 teams, how would the first round work? , randomly pair up teams?

Of those 10 we get five teams, and of those we get 2.5 teams?

we're programmers, we don't (atleast i) don't have a clue about how sports work.
Jan 19 '08 #2
ak1dnar
1,584 Expert 1GB
Really I also don't have a idea about the game. but it's better if you can create a diagram first, to identify the flow of the system.
Jan 19 '08 #3
Thanks for the replies...

Firstly there are 3 leagues with say 6 teams in each league.

To work out what teams are playing weekly i want to automatically work it out by how many points they have. For example:

1st vs 2nd
3rd vs 4th
5th vs 6th

The following week will be

1st vs 3rd
2nd vs 5th
3rd vs 6th

and so on like that.

I have to look into the database that i have with the points field, check the who has the most to least then input the teams name (which is in the same database as points) in to a format something like this

_____________ VS _________________ where the blanks are filled in automatically.

Hope that description helps a lil more

Thanks again

Matthew
Jan 19 '08 #4
This is what i am currently trying to use.

<?php

//opening the database
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="league_table"; // Database name
$tbl_name="league_2"; // Table name

// Connect to server and select databse.
$link=mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$query="SELECT Team_Name FROM league_2 ORDER BY Points DESC LIMIT 1";
$result=mysql_query($query);

if(!mysql_db_query($db_name,$query,$link)) die(mysql_error());

echo $result;

?>

The error that i am getting with this is: Resource id #3
Jan 19 '08 #5
I have now tried different approaches to this and have come up with a new error which is

Resource 5 error

Does anybody know how to do what i am trying and what these errors are?

Thanks
Jan 21 '08 #6
dlite922
1,584 Expert 1GB
I have now tried different approaches to this and have come up with a new error which is

Resource 5 error

Does anybody know how to do what i am trying and what these errors are?

Thanks
$result is exactly what you see, a resource.

you must Extract the data from it using one of MySQL builtin function such as mysql_fetch_assoc($result)

which gives you an associate array of the data, then you can loop to output it.

++++++++++++++++++++++++++++++++

as far as the leagues, can one team from one league play another?

Here's what i think should be done from your explanation:

I would query the DB and SORT them in DESCending order, then with a forloop pair them up in such a manner:
[PHP]
$pairedTeams = array();
for ($i = 0; $i < teamArr; $i++)
{
if(!empty($teamArr[$i] && !empty($teamArr[$i+1]))
{
$displayStr = $teamArr[$i] . " VS " . $teamArr[$i+1];
array_push($pairedTeams,$displayStr);
}
}

//then display your output
foreach ($pairedTeams as $pair)
{
echo $pair . "\n";
}


[/PHP]

the above should give you a display of:

1stTeamName VS 2ndBestTeam
3rdBestTeam VS 4thBestTeam

If you want the last 2 teams be dropped out, then you have to put a filter on the DB or the for loop above.

Maybe you query the DB and get the THIRD result when Sorting by score in ASCending order. you take this value and when you do your query you provide the condition WHERE score >= $thirdTeamFromBottom;

That should get rid of the bottom two teams with the lowest scores.
(that is if you don't want them deleted from the database)
Jan 21 '08 #7

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

Similar topics

1
by: Lynda McEwan | last post by:
I am having difficulty in writing a league program for a family member. I wrote a similar program many years ago in turbo pascal but am at a loss with vb. I will get there in the end but has anyone...
0
by: arthur | last post by:
I was wondering if there was any site with a public domain example of how league tables (such as football/soccer tables) could be maintained using ASP and Access databases. Thanks Arthur...
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: Ram | last post by:
Hi, I am trying to set up a DB for a race series where a riders best 6 of 10 rides count towards a league position. I have a table of Riders ( say 300 ) I want to use a form to select which...
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...
2
by: tommurray | last post by:
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....
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 ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.