Jump to content


This topic is now archived and is closed to further replies.


Enter scores - Seed after 2 games

Recommended Posts

I currently am using one table to display a tournament:

 id  int(11)
 age  int(11)
 game  int(11)
 day  varchar(25)
 time  varchar(10)
 field  varchar(50)
 team1  varchar(50)
 score1  int(11)
 score2  int(11)
 team2  varchar(50)
 diff  int(11)
 seed  int(11)
 pool  int(11)
 group  varchar(4)

Let's say I have a 4 team tournament, and the scores are this:

team1 score1 team2 score2
Reds 4 Pirates 3
Pirates 5 Astros 7
Astros 12 Mets 4
Mets 11 Reds 15

To get this data:

Team W L T RA RS Run Diff
Astros 2 0 0 9 19 10
Reds 2 0 0 14 19 5
Pirates 0 2 0 11 8 -3
Mets 0 2 0 27 15 -12

I am having to create the following EIGHT entries into my database:

team1 score1 team2 score2
Reds 4 Pirates 3
Pirates 3 Reds 4

Pirates 5 Astros 7
Astros 7 Pirates 5

Astros 12 Mets 4
Mets 4 Astros 12

Mets 11 Reds 15
Reds 15 Mets 11

And then doing the following PHP code to get them to sort and display:

$sql = 'SELECT id,team1, Sum(If(score1>score2,1,0)) AS Wins, Sum(If(score1<score2,1,0)) AS Losses, Sum(If(score1=score2,1,0)) AS Ties,Sum(score2) AS Allowed, Sum(score1) AS Scored, Sum(diff) AS Differential'
        . ' FROM tour'
        . ' WHERE age=10 AND day<>"Sun" AND (score1<>0 OR score2<>0)'
        . ' GROUP BY team1'
        . ' ORDER BY Wins DESC, Losses ASC, Allowed ASC, Scored DESC LIMIT 0, 30 ';

I have thought about 2 different ways to change this:

1) When I update a score, add another record with the teams inverted and the scores inverted
2) Do a lot of work and create a "normalized" database - which I believe I need to do

My current update code is below - I am updating each record with an update button -

I have searched for the code to do a list box for each game and each age, and then update that record - cannot find it -

Update form for age 10



*/ connect to table here

$result=mysql_query("SELECT * FROM tour WHERE age=10 AND day<>'Sun' ORDER BY game");
while ($i < $num) {

<table width="350" cellpadding="3" cellspacing="0" border="2">
<tr align="center" valign="top">
<td align="center" colspan="1" rowspan="1" bgcolor="ORANGE">

<form action="sat10u2.php" method="post">
<B>ID:<input type="text" name="ud_id" value="<? echo "$id"?>" size="1">
<B>Game: <input type="text" name="ud_game" value="<? echo "$game"?>" size="1">
<B>Team1: <input type="text" name="ud_team1" value="<? echo "$team1"?>" size="10">
<B>Score1: <input type="int" name="ud_score1" value="<? echo "$score1"?>" size="1">
<B>Score2: <input type="int" name="ud_score2" value="<? echo "$score2"?>" size="1">
<B>Team2: <input type="text" name="ud_team2" value="<? echo "$team2"?>" size="10">
<input type="Submit" value="Update">





*/connect to table code here

mysql_query(" UPDATE tour SET team1='$ud_team1' ,team2='$ud_team2',score1='$ud_score1',score2='$ud_score2' WHERE id='$ud_id'");
require 'sat10u.php';


I am sure some of you willing smart people could help me get in the right direction -


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.