Jump to content

tstats

Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tstats's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I would like to change the following update form - [code] <HTML> <FONT size=+2><B><I>Enter Games for your Tournament<BR><BR> <BR><BR> </B></I></FONT> </center> <body bgcolor="#ffffff"> <form action="updatescores.php" METHOD=POST ENCTYPE="multipart/form-data"> Age: <BR> <input type="checkbox" select name="age" value="7">7 <input type="checkbox" select name="age" value="8">8 <input type="checkbox" select name="age" value="9">9 <input type="checkbox" select name="age" value="10">10 <input type="checkbox" select name="age" value="11">11 <input type="checkbox" select name="age" value="12">12 <BR><BR> Game: <BR> <input type="checkbox" select name="game" value="1">1 <input type="checkbox" name="game" value="2">2 <input type="checkbox" name="game" value="3">3 <input type="checkbox" name="game" value="4">4 <input type="checkbox" name="game" value="5">5 <input type="checkbox" name="game" value="6">6 <input type="checkbox" name="game" value="7">7 <input type="checkbox" name="game" value="8">8 <BR><BR> <input type="submit" value="Enter Scores >>"> </form> <BR><BR> </body> </html> [/code] I would like to have the following for updatescores.php: When I choose the data for game and age, it brings up a php form that shows the following fields for editing for that age and game: id team1 team2 score1 score2 diff Where the Field names are: id autonumber 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) I have the following code - but it brings up ALL games instead of just the one that I want to edit: [code] <html> <body> <? $ud_id=$_POST['ud_id']; $ud_team1=$_POST['ud_team1']; $ud_team2=$_POST['ud_team2']; $ud_score1=$_POST['ud_score1']; $ud_score2=$_POST['ud_score2']; $ud_diff=$_POST['ud_diff']; *** */code for connecting to database is here *** mysql_query(" UPDATE tournament SET team1='$ud_team1' ,team2='$ud_team2',score1='$ud_score1',score2='$ud_score2' WHERE id='$ud_id'"); ?> </body> </html> [/code] Please let me know if you have any questions - I would appreciate any help on this! Thanks.
  2. 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: [code] $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 '; [/code] 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 sat10u.php [code] <?php */ connect to table here $result=mysql_query("SELECT * FROM tour WHERE age=10 AND day<>'Sun' ORDER BY game"); $num=mysql_num_rows($result); $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $game=mysql_result($result,$i,"game"); $team1=mysql_result($result,$i,"team1"); $score1=mysql_result($result,$i,"score1"); $team2=mysql_result($result,$i,"team2"); $score2=mysql_result($result,$i,"score2"); ?> <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"> <FONT SIZE="1"> <B>ID:<input type="text" name="ud_id" value="<? echo "$id"?>" size="1"> </B> <B>Game: <input type="text" name="ud_game" value="<? echo "$game"?>" size="1"> </B> <B>Team1: <input type="text" name="ud_team1" value="<? echo "$team1"?>" size="10"> </B><BR> <B>Score1: <input type="int" name="ud_score1" value="<? echo "$score1"?>" size="1"> </B> <B>Score2: <input type="int" name="ud_score2" value="<? echo "$score2"?>" size="1"> </B> <B>Team2: <input type="text" name="ud_team2" value="<? echo "$team2"?>" size="10"> </B> <input type="Submit" value="Update"> </form></FONT> </td></tr></table> <? ++$i; } ?> [/code] sat10u2.php [code] <html><head><title></title></head> <body> <? $ud_id=$_POST['ud_id']; $ud_team1=$_POST['ud_team1']; $ud_team2=$_POST['ud_team2']; $ud_score1=$_POST['ud_score1']; $ud_score2=$_POST['ud_score2']; $ud_seed=$_POST['ud_seed']; */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'"); mysql_close($link); require 'sat10u.php'; ?> </body> </html> [/code] I am sure some of you willing smart people could help me get in the right direction - Thanks!
  3. Thanks for all of your help on this subject - I have two pieces of code - the first set of code is here: [code] <html><head><title></title></head> <body> <? $ud_id=$_POST['ud_id']; $ud_score1=$_POST['ud_score1']; $ud_score2=$_POST['ud_score2']; $ud_diff=$_POST['ud_diff']; //connect to db with password above this line mysql_select_db($db , $link) or die("Couldn't open $db: ".mysql_error()); mysql_query(" UPDATE acsb061 SET score1='$ud_score1',score2='$ud_score2', diff='$ud_diff' WHERE id='$ud_id'"); mysql_close($link); require 'updatenext.php'; ?> </body> </html> [/code] The second set of code is here - which updates the database - [code] <html><head><title></title></head> <body> <? $ud_id=$_POST['ud_id']; $ud_score1=$_POST['ud_score1']; $ud_score2=$_POST['ud_score2']; $ud_diff=$_POST['ud_diff']; $db = "tourname_Tour"; $link = mysql_connect("localhost","tourname","tmrcdrdlr"); if (! $link) die("Couldn't connect to MySQL"); mysql_select_db($db , $link) or die("Couldn't open $db: ".mysql_error()); mysql_query(" UPDATE acsb061 SET team1='$ud_team1' ,team2='$ud_team2',score1='$ud_score1',score2='$ud_score2', diff='$ud_diff' WHERE id='$ud_id'"); mysql_close($link); require 'updatefirst.php'; ?> </body> </html> [/code] Ok - so here is my question. Right now, I am having to enter the $diff in the html form - how would I write it so that the $diff in code set 1 above would be calculated? I would just enter the two scores and the $diff field (which is score1 - score2) would automatically be calculated and then passed through to the updatenext.php file - Thanks for the help -
×
×
  • Create New...

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.