I would like ot posdt the code but it is very long but here it is, if it doesnt all fit please email me and i will email them back as attachments email is brooks@paisd.net
Thanks
AddBasketball.php...
<?
// you need to call the functions include
require("functions.php");
// submit pressed
if($submit){
// do it all
addgamestats($sport);
// print confirmation
print("<center><b>Game successfully added.</b></center>");
}else{
?>
<head>
<title>Administration</title>
</head>
<body bgcolor="#ffffff">
<center><font face="arial" size="6"><b>Basketball
Score Sheet</b></font></center>
<center><font face="arial" size="1">Fields denoted in <font color="red">red</font> are required.</font></center>
<center>This is a demo on how i want it to look, just hit submit, you dont
have to put any info in, and hit submit. and then choose a game, this is
just how i would like it to work and function basicly. <pre> </pre>
<FORM METHOD="POST" ACTION="AddBasketball.php?sport=basketball">
<center><table border=0>
<tr>
<td><font face="arial" size="2" color="red"><b>Select One</b></font>
<br><br><br></td>
<td><font face="arial" size="2"><SELECT
NAME="teamtype" SIZE="1">
<OPTION SELECTED>
<OPTION>Varsity Boys Basketball
<OPTION>Varsity Girls Basketball
<OPTION>JV Boys Basketball
<OPTION>JV Girls Basketball
</SELECT>
<br>
<br>
<br>
</td>
</tr>
<tr><td><b>Marlins - </b></td>
</tr>
<tr>
<td><font face="arial" size="2"><b>First Period:</b>
<INPUT NAME="period1marlins" SIZE="3" MAXLENGTH="5"></font></td>
<td><font face="arial" size="2"><b>Second Period:</b></font>
<font face="arial" size="2"><INPUT
NAME="period2marlins" SIZE="3" MAXLENGTH="5"></font></td>
<td><font face="arial" size="2"><b>Third Period:</b>
<INPUT NAME="period3marlins" SIZE="3" MAXLENGTH="5"></font></td>
<td><font face="arial" size="2"><b>Forth Period:</b>
<INPUT NAME="period4marlins" SIZE="3" MAXLENGTH="5"></font></td>
</tr>
<tr>
<td><font face="arial" size="2"><b>Leading Scorer:</b></td>
<td><INPUT NAME="scorermarlins" SIZE=15" MAXLENGTH="20"></font></td>
</tr>
<tr>
<td><font face="arial" size="2"><b>Lead Rebounder:</b>
<br>
<br>
</td>
<td><INPUT NAME="reboundermarlins" SIZE="15" MAXLENGTH="20"></font></td>
</tr>
<tr><td><b>Other Team:</b>
<br>
<INPUT NAME="otherteam" SIZE="10" MAXLENGTH="15">
</td>
</tr>
<tr>
<td><font face="arial" size="2"><b>First Period:</b>
<INPUT NAME="period1opp" SIZE="3" MAXLENGTH="5"></font></td>
<td><font face="arial" size="2"><b>Second Period:</b></font>
<font face="arial" size="2"><INPUT
NAME="period2opp" SIZE="3" MAXLENGTH="5"></font></td>
<td><font face="arial" size="2"><b>Third Period:</b>
<INPUT NAME="period3opp" SIZE="3" MAXLENGTH="5"></font></td>
<td><font face="arial" size="2"><b>Forth Period:</b>
<INPUT NAME="period4opp" SIZE="3" MAXLENGTH="5"></font></td>
</tr>
<tr>
<td><font face="arial" size="2"><b>Leading Scorer:</b></td>
<td><INPUT NAME="scoreropp" SIZE=15" MAXLENGTH="20"></font></td>
</tr>
<tr>
<td><font face="arial" size="2"><b>Lead Rebounder:</b>
<br>
<br>
</td>
<td><INPUT NAME="rebounderopp" SIZE="15" MAXLENGTH="20"></font></td>
</tr>
<tr>
<td>
<br>
<br>
<font face="arial" size="2"><b>Comments:</b></font></td>
</tr>
<tr>
<td colspan=4><CENTER><TEXTAREA NAME="gamenotes" ROWS="5" COLS="51" WRAP="VIRTUAL"></TEXTAREA></CENTER></td>
</tr>
</table></center>
<P>
<CENTER><INPUT TYPE="SUBMIT" name="submit" VALUE="Submit New Game"> <INPUT
TYPE="RESET" VALUE="Reset Values"></CENTER></FORM>
</body>
<?}?>
functions.php...
<?
function uploadgameinfo($sport,$filename,$filedata){
// open the file in the directory for the given sport
$file=fopen("$sport/$filename", "a+");
// write to the page on the server
fwrite($file, "$filedata\n");
// close the file connection
fclose($file);
}
// declare the function
function addgamestats($sport){
// we will use basketball as the example here, you can change the form fields around for the other sports
if($sport=='basketball'){
// declare all of the form variables used on the form
global
$teamtype,$period1marlins,$period2marlins,$period3marlins,$period4marlins,$scorermarlins,
$reboundermarlins,$otherteam,$period1opp,$period2opp,$period3opp,$period4opp,$scoreropp,
$rebounderopp,$gamenotes;
// piece together the score line for both teams
$scoremarlins ="$period1marlins-$period2marlins-$period3marlins-$period4marlins";
$scoreopp = "$period1opp-$period2opp-$period3opp-$period4opp";
// piece together the leading scorers and rebounders for each team (first the scorers, then the rebounders)
$leadermarlins = "$scorermarlins-$reboundermarlins";
$leaderopp = "$scoreropp-$rebounderopp";
// now start writing to each of the text files using the first function we made
// type of game and game info
uploadgameinfo("basketball","teamtype.txt",$teamtype);
uploadgameinfo("basketball","otherteam.txt",$otherteam);
// Marlins' and opponents scores
uploadgameinfo("basketball","scoremarlins.txt",$scoremarlins);
uploadgameinfo("basketball","scoreopp.txt",$scoreopp);
// game leaders (you could have the coaches put their points in brackets after their names, if you like)
uploadgameinfo("basketball","leadersmarlins.txt",$leadersmarlins);
uploadgameinfo("basketball","leadersopp.txt",$leadersopp);
// finally, the game notes
uploadgameinfo("basketball","gamenotes.txt",$gamenotes);
}
// end basketball
}
// end function
function readgameinfo($sport,$filename){
global $gameid;
// open and read the specified file
$file = fopen("$sport/$filename","r");
// read the contents of the file
$filecontents = fread($file,filesize($file));
//print$filecontents;
// break apart the games to count them
$gamepieces = explode("\n",$filecontents);
// remember that we had to add 1 to the game number in the last function, now we have to subtract it back, as PHP starts counting at 0.
$newgameid=$gameid-1;
// extract the info from the given file for the game you want
for($i=0;$i<=count($gamepieces);$i++){
// there will only be one row of game stats that you're looking for, then you can kill the function
if($i==$newgameid){
$gameinfo = $gamepieces[$i];
}
}
// return the information you retrieved
return($gameinfo);
}
?>
games.php....
<?
// retrieve the list of games played, with links to more detailed information on each of those games
require("functions.php");
// no specific game has been selected
if(!$gameid){
// open the list of games in the "otherteam.txt" file (you could alternately use the date of the game as the comparitive file)
$file = fopen("basketball/otherteam.txt","r");
// read the contents of the file
$filecontents = fread($file,filesize($file));
// break apart the games to count them
$gamepieces = explode("\n",$filecontents);
// for each game, display a row with a link to that game info
for($i=0;$i<count($gamepieces);$i++){
// we want to start the game number at one, not zero (PHP starts counting at 0)
$newgameid=$i+1;
// the row with the game link (this assumes you are in the basketball folder)
$gameblock .="<a href=\"games.php?gameid=$newgameid\">Game $newgameid</a><br>";
}
}else{
// a game has been set, retrieve the game information (the function for this is described underneath)
// this part is a bit bulky, as you will need to open all of the games and sort through them (the last function will take care of this)
// the type of game and the teams playing
$teamtype=readgameinfo("basketball","teamtype.txt");
$otherteam=readgameinfo("basketball","otherteam.txt");
// open and break apart the different scores, by period
$periodsmarlins=readgameinfo("basketball","scoremarlins.txt");
$periodpieces=explode("-",$periodsmarlins);
for($i=0;$i<4;$i++){
// add one again
$periodnumber = $i+1;
// prepare variable for variable variable
$period = "marlinsperiod$periodnumber";
// create a new variable called "marlinsperiod1", "marlinsperiod2", etc)
$$period = $periodpieces[$i];
// tally the total score
$opptotalscore = $opptotalscore + $periodpieces[$i];
}
// clear rogue variables
unset($periodpieces);
// do the exact same thing for the other team
$periodsopp=readgameinfo("basketball","scoreopp.txt");
$periodpieces=explode("-",$periodsopp);
for($i=0;$i<4;$i++){
// add one again
$periodnumber = $i+1;
// prepare variable for variable variable
$period = "oppperiod$periodnumber";
// create a new variable called "oppsperiod1", "oppperiod2", etc)
$$period = $periodpieces[$i];
// tally the total score
$opptotalscore = $opptotalscore + $periodpieces[$i];
}
// open the scoring/rebounding leaders
$leadersmarlins = readgameinfo("basketball","leadersmarlins.txt");
// separate the leading scorer from the leading rebounder
$leaders = explode("-",$leadersmarlins);
$scorermarlins = $leaders[0];
$reboundermarlins = $leaders[1];
// same for the other theam
$leadersopp = readgameinfo("basketball","leadersopp.txt");
// separate the leading scorer from the leading rebounder
$leaders = explode("-",$leadersopp);
$scoreropp = $leaders[0];
$rebounderopp = $leaders[1];
// open your game notes
$gamenotes = readgameinfo("basketball","gamenotes.txt");
}
?>
<head>
<title>Basketball Games</title>
</head>
<body bgcolor=blue text=white alink=black vlink=black link=black>
<center><?
// no game shown, display menu of games
if(!$gameid){
print $gameblock;
?></center>
<?
}else{
// specific game requested, display to your liking
?>
<h3>Game <?print $gameid?></h3>
<p><b><?print $teamtype?></b>
<b>Marlins</b> -v- <b><?print $otherteam?></b><br><br>
<b>Marlins</b>:
<table border=1 cellspacing=3>
<td>First Period: <?print $marlinsperiod1?></td>
<td>Second Period: <?print $marlinsperiod2?></td>
<td>Third Period: <?print $marlinsperiod3?></td>
<td>Fourth Period: <?print $marlinsperiod4?></td>
<td>Final Score: <?print $totalscoremarlins?></td>
</table>
<br>
<b><?print $otherteam?></b>:
<table border=1 cellspacing=3>
<td>First Period: <?print $oppperiod1?></td>
<td>Second Period: <?print $oppperiod2?></td>
<td>Third Period: <?print $oppperiod3?></td>
<td>Fourth Period: <?print $oppperiod4?></td>
<td>Final Score: <?print $totalscoreopp?></td>
</table>
Leading scorers:<br>
Marlins-<?print$scorermarlins?>, <?print$otherteam?>-<?print$scoreropp?>
Leading rebounders:<br>
<?print$reboundermarlins?>, Marlins, <?print$rebounderopp?>,
<?print$otherteam?>
Coaches' remarks:
<?print $gamenotes?>
<?}?>
</body>
see its long and alot of scripting...if you can read this much.
Thanks,
Brooks