472,111 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,111 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 2066
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

Post your reply

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

Similar topics

1 post views Thread by Lynda McEwan | last post: by
reply views Thread by arthur | last post: by
2 posts views Thread by Richard Williamson | last post: by
3 posts views Thread by Ram | last post: by
2 posts views Thread by minus | last post: by
4 posts views Thread by minus | last post: by
reply views Thread by leo001 | last post: by

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.