Jump to content

Archived

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

jetpacmidge

Football Tables

Recommended Posts

Hi

 

I am new to using PHP and MYSQL. I am designing a website so that I can update football tables where the user can enter the results which automatically updates the tables.

 

Please find attached a zipped file of what I have achieved so far.

 

I am using Linux running apache webserver, PHP and MYSQL.

 

These are the problems that I have with my interactive website :-

 

1. You can enter results by not filling in all the fields. This should not happen as all fields should be filled in NOT NULL in creating the tables for the database ?

 

2. How do I solve the problem of when the results have been entered the tables have been updated and show the correct standings for each team ?

 

3. How do I add points goal difference etc to the tables ?

 

Below is a list of programs for my web site as I cannot send an attached as a zip file !!

 

AddResult.php - Confirmation Screen when result has been entered on web site.

 

<?php

/* Program: AddResult.php

* Desc: A confirmation screen

* is sent to the user.

*/

 

$season = $_POST[\'season\'];

$fixtureDate = $_POST[\'fixtureDate\'];

$age = $_POST[\'age\'];

$homeTeam = $_POST[\'homeTeam\'];

$homeScore = $_POST[\'homeScore\'];

$awayTeam = $_POST[\'awayTeam\'];

$awayScore = $_POST[\'awayScore\'];

 

if (@$_POST[\'newbutton\'] == \"Cancel\")

{

header(\"Location: tadburnfc.htm\");

}

if ($homeTeam == \"new\")

{

if ($newhomeTeam == \"\") // if the text field is blank

{

include(\"NewResultform.inc\");

exit();

}

else

{

$homeTeam = $newhomeTeam;

}

}

 

 

 

?>

<html>

<head><title>Add Result</title></head>

<?php

include(\"connection.inc\");

$connection = mysql_connect($host,$user,$password)

or die (\"couldn\'t connect to server\");

$db = mysql_select_db($database,$connection)

or die (\"Couldn\'t select database\");

 

$query = \"INSERT INTO results (season,fixtureDate,age,homeTeam,homeScore,awayTeam,awayScore)

VALUES (\'$season\',\'$fixtureDate\',\'$age\',\'$homeTeam\',\'$homeScore\',\'$awayTeam\',\'$awayScore\')\";

$result = mysql_query($query)

or die (\"Couldn\'t execute query.\");

 

include(\"Confirmation_form.inc\");

 

 

?>

</body>

</html>

 

Confirmation Form

 

<?php

/* Program: NewResultform.inc

* Desc: Displays form to collect the result information

*/

?>

<BODY BGCOLOR=\"FAFAD2\" TEXT=\"00008B\" LINK=\"00008B\" VLINK=\"00008B\" ALINK=\"00008B\">

 

 

<center>

<b><font face=\"Arial, Helvetica, sans-serif\" size=\"+4\" color=\"#0000FF\">Confirmation</font></b>

</center>

<br>

<br>

<font face=\"Arial, Helvetica, sans-serif\" size=\"+2\" color=\"#0000FF\">

 

<?php

echo \"The following result has been added to Tadburn FC Database: n\"

?>

<br>

<br>

<br>

<?php echo\" Season: $season n\" ?>

<br>

<br>

<table border=\"0\" width=\"75%\">

 

<tr>

<th align=\"center\">Fixture Date</th>

<th align=\"center\">Age</th>

<th align=\"center\">Home Team</th>

<th align=\"center\">Home Score</th>

<th align=\"center\">Away Team</th>

<th align=\"center\">Away Score</th>

</tr>

<tr>

<td align=\"center\"><?php echo $fixtureDate ?> </td>

<td align=\"center\"><?php echo $age ?></td>

<td align=\"center\"><?php echo $homeTeam ?></td>

<td align=\"center\"><?php echo $homeScore ?></td>

<td align=\"center\"><?php echo $awayTeam ?></td>

<td align=\"center\"><?php echo $awayScore ?></td>

</tr>

 

</table>

 

<br>

<br>

<br>

 

<?php echo \"Add Another Result ? <a href=\'results.php\'>YES</a>n\"?>

 

<?php echo \"<a href=\'tadburnfc.htm\'>NO</a>n\"?>

 

</font>

 

Connection.inc file to connect to database.

 

<?php

$user=\"root\";

$host=\"localhost\";

$password=\"\";

$database=\"Tadburnfc\";

?>

 

CREATETABLES.BASH executable file to create tables for database.

 

mysql -B <<EOF

#use Tadburnfc;

#show databases;

#use Slotcars;

#show tables;

use Tadburnfc;

drop table teams;

drop table results;

drop table leagueTable;

create table teams (

season CHAR(7) NOT NULL,

age CHAR(15) NOT NULL,

team CHAR(30) NOT NULL,

PRIMARY KEY(season, age, team) );

 

create table results (

season CHAR(7) NOT NULL,

age CHAR(15) NOT NULL,

homeTeam CHAR(30) NOT NULL,

awayTeam CHAR(30) NOT NULL,

fixtureDate DATE NOT NULL,

homeScore INT(3) UNSIGNED NOT NULL,

awayScore INT(3) UNSIGNED NOT NULL,

PRIMARY KEY(season, age, homeTeam, awayTeam) );

 

create table leagueTable (

season CHAR(7) NOT NULL,

age CHAR(15) NOT NULL,

team CHAR(30) NOT NULL,

played INT(2) UNSIGNED NOT NULL,

homewins INT(2) UNSIGNED NOT NULL,

homedefeats INT(2) UNSIGNED NOT NULL,

homedraws INT(2) UNSIGNED NOT NULL,

homefor INT(3) UNSIGNED NOT NULL,

homeagainst INT(3) UNSIGNED NOT NULL,

awaywins INT(2) UNSIGNED NOT NULL,

awaydefeats INT(2) UNSIGNED NOT NULL,

awaydraws INT(2) UNSIGNED NOT NULL,

awayfor INT(3) UNSIGNED NOT NULL,

awayagainst INT(3) UNSIGNED NOT NULL,

points INT(3) UNSIGNED NOT NULL,

goaldiff INT(4) NOT NULL,

PRIMARY KEY(season, age, team) );

show tables;

describe teams;

describe results;

describe leagueTable;

EOF

 

INITIALDATATEAMS.BASH - file exectuable data for database

 

mysql -B <<EOF

use Tadburnfc;

#INSERT INTO teams ( season, age, team ) VALUES (\"2003/04\", \"Under 9 Blue\", \"Tadburn Panthers\");

 

 

 

#INSERT INTO leagueTable (

# season,

# age,

# team,

# played,

# homewins,

# homedefeats,

# homedraws,

# homefor,

# homeagainst,

# awaywins,

# awaydefeats,

# awaydraws,

# awayfor,

# awayagainst,

# points,

# goaldiff )

#INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 9 Blue\", \"Tadburn Panthers\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 9 Blue\", \"Townhill Cobras\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 9 Blue\", \"Earls Rangers\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 9 Blue\", \"Colden Common B\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 9 Blue\",\"Dougland\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 9 Blue\", \"Pace Cougars\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 9 Blue\", \"East Park Rangers\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 9 Blue\", \"Brendon\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 9 Blue\", \"Littleton Lions\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Red\", \"Albion Rovers\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Red\", \"Winchester\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Red\", \"Langley Manor\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Red\", \"Tadburn Cougars\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Red\", \"Marchwood Black\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Red\", \"S&D\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Red\", \"Baddesley Park\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Red\", \"Littleton Leopards\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Blue\", \"Colden Common B\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Blue\", \"Millbrook Lions\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Blue\", \"Colden Common A\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Blue\",\"Michelmersh & Timsbury\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Blue\", \"East Park Rangers\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Blue\", \"Littleton Lynx\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Blue\", \"Dougland Blue\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Blue\", \"Hythe Strikers\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Blue\", \"Townhill Eagles\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 10 Blue\", \"Tadburn Panthers\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 15s\", \"Ice Sports\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 15s\",\"Albion\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 15s\", \"Testwood\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 15s\", \"Mansbridge\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 15s\", \"Botley\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 15s\", \"Colden Common\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 15s\", \"Tadburn\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 13s\", \"Tadburn\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 13s\", \"Fawley\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 13s\",\"Hiltingbury\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 13s\", \"Springhill\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 13s\", \"St Francis C\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 13s\", \"Calmore\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 13s\", \"Winchester\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 13s\", \"Colden Common A\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 13s\", \"Royals\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 12s\", \"Winsor\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 12s\",\"Lordswood A\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 12s\", \"BTC Solent\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 12s\", \"Itchen\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 12s\", \"Fawley\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 12s\", \"Hythe S A\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 12s\", \"Hythe H\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 12s\", \"Brendon\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 12s\", \"Earls\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 12s\", \"Tadburn\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\", \"Littleton A\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\", \"Testwood\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\", \"Tadburn C\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\",\"Warsash\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\", \"Fawley A\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\", \"Netley\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\", \"St Francis Rangers\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\", \"Ice\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\", \"Calmore\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\", \"Townhill A\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\", \"Tadburn P\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\", \"Alresford\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\", \"Earls S\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\", \"Winsor A\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\", \"Hythe H\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\",\"Regents Park\");

INSERT INTO leagueTable ( season, age, team) VALUES ( \"2003/04\", \"Under 11s\", \"Sky Blues\");

 

EOF

 

 

NEWRESULTFORM- Displays new form if not all fileds have been entered.

 

<?php

/* Program: NewResultform.inc

* Desc: Displays form to collect the result information

*/

?>

<b>You must fill in all the information to enter the result.</b>

<form action=\"AddResult.php\" method=\"post\">

 

<input type=\"hidden\" name=\"season\" value=\"<?php echo $season ?>\">

<input type=\"hidden\" name=\"fixtureDate\" value=\"<?php echo $fixtureDate ?>\">

<input type=\"hidden\" name=\"age\" value=\"<?php echo $age ?>\">

<input type=\"hidden\" name=\"homeTeam\" value=\"<?php echo $homeTeam ?>\">

<input type=\"hidden\" name=\"homeScore\" value=\"<?php echo $homeScore ?>\">

<input type=\"hidden\" name=\"awayTeam\" value=\"<?php echo $awayTeam ?>\">

<input type=\"hidden\" name=\"awayScore\" value=\"<?php echo $awayScore ?>\">

<p><input type=\"submit\" name=\"newbutton\" value=\"Enter new result\">

<input type=\"submit\" name=\"newbutton\" value=\"Cancel\">

</form>

 

 

NewResulttable.inc - for to show new results.

 

<?php

/* Program: NewResulttable.inc

* Desc: Displays table to enter the results

*/

?>

<center>

<b><font face=\"Arial, Helvetica, sans-serif\" size=\"+3\" color=\"#0000FF\">Results</font></b>

</center>

<br>

<br>

<font face=\"Arial, Helvetica, sans-serif\" size=\"+1\" color=\"#0000FF\">

<p>Enter the football score on the form below !!</p>

<br>

<br>

 

<font face=\"Arial, Helvetica, sans-serif\" color=\"#0000FF\">

 

<table border=\"0\">

<tr><td align=\"right\">Season :</td>

<td><input type=\"text\" name=\"season\"

value=\"<?php echo $season ?>\"

size=\"7\" maxlength=\"7\"> (enter season as 2003/04)</td>

 

<tr><td align=\"right\">Fixture Date :</td>

<td><input type=\"text\" name=\"fixtureDate\"

value=\"<?php echo $fixtureDate ?>\"

size=\"12\" maxlength=\"12\"> (enter date as 2003-mm-dd)</td>

</tr>

<tr><td align=\"right\">Age Group :</td>

<td><input type=\"text\" name=\"age\"

value=\"<?php echo $Condition ?>\"

size=\"15\" maxlength=\"15\">

</td></tr>

<tr><td align=\"right\">Home Team :</td>

<td><input type=\"text\" name=\"homeTeam\"

value=\"<?php echo $homeTeam ?>\" size=\"30\" maxlength=\"30\">

</td></tr>

<tr><td align=\"right\">Home Score :</td>

<td><input type=\"text\" name=\"homeScore\"

value=\"<?php echo $homeScore ?>\" size=\"3\" maxlength=\"3\">

 

<tr><td align=\"right\">Away Team :</td>

<td><input type=\"text\" name=\"awayTeam\"

value=\"<?php echo $awayTeam ?>\" size=\"30\" maxlength=\"30\">

</td></tr>

<tr><td align=\"right\">Away Score :</td>

<td><input type=\"text\" name=\"awayScore\"

value=\"<?php echo $awayScore ?>\" size=\"3\" maxlength=\"3\">

 

</table>

</font>

 

results.php - allows user to enter results.

 

<?php

/* Program: Results.php

* Desc: Allows the Administrator to enter the football

* results which updates the tables.

*/

?>

<HTML>

 

<HEAD>

 

<TITLE>Results</TITLE>

<STYLE>

<!--

A {text-decoration: none; color:#00008B}

-->

</STYLE>

</HEAD>

 

<BODY BGCOLOR=\"FAFAD2\" TEXT=\"00008B\" LINK=\"00008B\" VLINK=\"00008B\" ALINK=\"00008B\">

 

<?php

include(\"connection.inc\");

 

 

$connection = mysql_connect($host,$user,$password)

or die (\"couldn\'t connect to server\");

$db = mysql_select_db($database,$connection)

or die (\"Couldn\'t select database\");

 

/* create form */

 

echo \"<form action=\'AddResult.php\' method=\'post\'>n\";

 

 

 

include(\"NewResulttable.inc\");

 

 

 

 

 

 

echo \"<p><input type=\'submit\' value=\'Submit Result\'>

<input type=\'submit\' name=\'newbutton\' value=\'Cancel\'>

</form>n\";

?>

</div>

</body>

</html>

 

 

</BODY>

 

</HTML>

 

Any help with my website would be much appreciated.

 

Regards,

 

Andy M. :)

Share this post


Link to post
Share on other sites

Ack too much information... to many questions. Try breaking em down one at a time. You will probably have more luck.

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.