Jump to content

ade2901

Members
  • Posts

    30
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

ade2901's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am wondering if anything can begin to point me in the right direction... I am trying to create a fixture generator for a local football league and I can't seem to get my head around where to start. My idea was to start with getting it working for one of the three divisions and go from there. I don't have a clue how to start on generating the fixtures but I know that I will need find out the total number of teams in the division via a simple query so that it can be stored in a variable and used in the algorithm. The biggest issue I have is that some teams share pitches and they obviously cannot play on the same game week. Furthermore the teams must play each other once at home and once away. If anyone could perhaps point me in the right direction or provide any sort of assistance I would be very appreciative. I can't find anything online that generates fixtures and stores them in a database. Ones I have found seem overly complicated and I can't get my head around them. All help is appreciated. Thanks.
  2. Solved using a different method I decided to try... Here is the solution: $query = mysql_query("SELECT * FROM tableName WHERE ID='$ID'")or die(mysql_error()); $row = mysql_fetch_array($query); /*Player DOB Exploding*/ $year = date('Y', strtotime( $row['dateColumn'] ) ); $month = date('m', strtotime( $row['dateColumn'] ) ); $day = date('d', strtotime( $row['dateColumn'] ) );
  3. Hi, I wonder if someone can help me... I am trying to extract the date into three different variables ready to go into three option boxes for the user to update a person's date of birth. I am using the following to split up the day, month and year: $queryDate = mysql_query("SELECT YEAR(playerDOB), MONTH(playerDOB), DAY(playerDOB) FROM player WHERE playerID='$playerID'") or die (mysql_error()); Now I have tried this within the database and can see that it splits it up. The problem I am having is being able to access them in variables. How do I go about accessing the year, day and month separately from the $queryDate variable? Appreciate the help in advance!
  4. Thanks Requinix, turns out it was the magic quotes.. I had wondered! Only problem now is that when you go to edit the data the apostrophies are omitted from the 'headline' field. Does anyone know where I could be going wrong with this? This will relate to the code "Here is the PHP to view the data ready to edit:" All help as always is extremely appreciated!
  5. Hi, thanks for that. I'll give it a go tomorrow. The reason I have stripslashes is because it prints out the slashes entered into the database as it isn't removing them when the data is entered into the database. Locally it seems to nearly work but on the server It's entirly different.. the slashes are stored in the database on the server hence the need to strip slashes. On my local server the slashes aren't stored. Very strange.. Thanks again for your reply :-).
  6. Hi all, I've been having some trouble with the whole slashes and apostrophy situation. When the user enters into the database locally they can enter in apostophies no problem and it outputs on the site no problem. When the user edits the data it then alters it and removes apostrophies from the headline field, not the text editor field (tinyMCE). However, when I test it on the web (it's secured so I am unable to provide a link), there are more problems, those being that when it enters into the database it adds slashes where there are apostrophies but doesn't do this locally... Could this by a PHP version issue? Version 5.3.5 on the web and 5.3.1 locally. In addition when the you come to edit the data all of the apostropies and following letter have been removed and slashes put in their place. But as I say this doesn't happen locally.. Here is the insert statement: <?php require_once('auth.php'); ?> <?php $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $newsHeadline = $_POST['newsHeadline']; $newsContent = $_POST['newsContent']; $query = "INSERT INTO news (newsDate, newsHeadline, newsContent) VALUES ('".date("l"." "."j"." "."F"." "."Y")."','".mysql_real_escape_string($newsHeadline)."','".mysql_real_escape_string($newsContent)."')"; if(mysql_query($query)) { echo "News successfully inserted.<br/><a href='addNews.php'>Back to main page</a><br/>"; }else echo "Encountered an error.".mysql_error()."<a href='javascript:history.go(-1)'>Click here to go back</a><br/>"; // close connection mysql_close(); ?> Here is the php to output the text // while there are rows to be fetched... while ($list = mysql_fetch_assoc($resultSelectNewsData)) { // echo data echo "<div class='newsArticle'><p class='newsHeadline'>"; echo stripslashes ($list['newsHeadline']); echo "<br /><span class='nDate'>Posted on: ".$list['newsDate']."</span></p><div class='newsContent'><p>"; echo stripslashes ($list['newsContent']); echo "</p></div><!--news content end--><br /></div><!--news article end-->"; } // end while Here is the PHP to view the data ready to edit: <?php require_once('auth.php'); ?> <?php $pagetitle = "Langbaurgh Sunday League";?> <?php include("includesAdmin/header.php");?> <?php include("includesAdmin/nav.php");?> <div id="mainContentAdmin"> <h1>Admin Panel</h1> <?php // Make a MySQL Connection $newsID=$_GET['newsID']; //Query to join tables and obtain team names linked to IDs $sql2= mysql_query ("SELECT * FROM news WHERE newsID = '$newsID'")or die(mysql_error()); echo "<form name='editDetails' method='post' action='php_update_news_item.php'>"; $row = mysql_fetch_array($sql2); // Print out the contents of each row echo "<input type='hidden' name='newsID' id='newsID' size='15' value='".$row['newsID']."'/>"; echo"News Headine: <br /><input type='text' name='newsHeadline' id='newsHeadline' size='40' value='".$row['newsHeadline']."'/><br />"; echo"News Story: <br /><textarea name='newsContent' id='newsContent' cols='50' rows='15'>".$row['newsContent']."</textarea>"; echo "<input type='submit' name='submit' value='Update News Story'/>"; mysql_close(); ?> </div><!--contentAreaEnd--> <?php include("includesAdmin/footer.php");?> Here is the file to update the data <?php require_once('auth.php'); ?> <?php $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $newsID = $_POST['newsID']; $newsHeadline = $_POST['newsHeadline']; $newsContent = $_POST['newsContent']; $query = "UPDATE news SET newsHeadline='".mysql_real_escape_string($newsHeadline)."', newsContent='".mysql_real_escape_string($newsContent)."' WHERE newsID='".mysql_real_escape_string($newsID)."'"; if(mysql_query($query)) { echo "News successfully updated.<br/><a href='view_news_id.php'>Back to news viewing</a><br/>"; }else echo "Encountered an error.".mysql_error()."<a href='javascript:history.go(-1)'>Click here to go back</a><br/>"; // close connection mysql_close(); ?> All help would be massively appreciated as I am really stuck with this. I've tried all sorts including stripslashes, trim, a combination of both, yet I hit snags with each one of them.. Many thanks in advance, Aidan
  7. phpSensei; I see what you're saying. Initially I thought the issue lay with the PHP coding hence placing it in here. Still not 100% sure if it is my PHP code that is causing it nor not, I think it might be though!
  8. Apologies, it's extremely messy! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Division 1 Fixtures | Langbaurgh Sunday League</title><link rel="stylesheet" type="text/css" href="../style.css" /> <link rel="stylesheet" type="text/css" href="../jqueryslidemenu.css" /> <link rel='stylesheet' type='text/css' href='../stylePHP.php' /> <!--[if lte IE 7]> <style type="text/css"> html .jqueryslidemenu{height: 1%;} /*Holly Hack for IE7 and below*/ </style> <![endif]--> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script> <script type="text/javascript" src="../jqueryslidemenu.js"></script> </head> <body> <div id="wrapper"> <div id="header"> <h1>Langbaurgh Sunday League</h1> </div><!--header end--> <div id="myslidemenu" class="jqueryslidemenu"> <ul> <li><a href="http://www.dynamicdrive.com">League News</a></li> <li><a href="http://www.dynamicdrive.com">About</a></li> <li><a href="#">Division 1</a> <ul> <li><a href="../division1/div1Fixtures.php">Fixtures</a></li> <li><a href="../division1/division1Table.php">League Table</a></li> <li><a href="../division1/division1Contacts.php">Club Details</a></li> </ul> </li> <li><a href="#">Division 2</a> <ul> <li><a href="../division2/div1Fixtures.php">Fixtures</a></li> <li><a href="../division2/div1Table.php">League Table</a></li> <li><a href="../division2/clubDetails.php">Club Details</a></li> </ul> </li> <li><a href="#">Division 3</a> <ul> <li><a href="../division3/div1Fixtures.php">Fixtures</a></li> <li><a href="../division3/div1Table.php">League Table</a></li> <li><a href="../division3/clubDetails.php">Club Details</a></li> </ul> </li> <li><a href="#">Cup Competitions</a> <ul> <li><a href="../cupCompetitions/leaguecup.php">League Cup</a></li> <li><a href="../cupCompetitions/terrysmith.php">Terry Smith</a></li> <li><a href="../cupCompetitions/terrymay.php">Terry May</a></li> </ul> </li> <li><a href="#">League History</a></li> <li><a href="#">League Documents</a></li> <li><a href="#">Contact Us</a></li> </ul> <br style="clear: left" /> </div><!--navigation end--> <div id="contentArea"> <div id="mainContent"> <h1>LSL Division 1 Team Contacts</h1> <br /> <br /> <div id='teamDetails'><div style='background-color:#FFFFFF;'><div class='teamName'><p class='teamName'>Acklam Electrical</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Matty Mitchell - 01642123456 / 07777 777777 - matty.mit@abc.com</p><p class='teamAllDetails'><b>Assistant Secretary:</b> - / - </p><p class='teamAllDetails'><b>Home Colours:</b> Red & Black</p><p class='teamAllDetails'><b>Away Colours:</b> White</p><p class='teamAllDetails'><b>Home Venue:</b> Mill Hill</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#E8E8E8;'><div class='teamName'><p class='teamName'>Cleveland Cable</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Anthony Massingham - 01642123456 / - </p><p class='teamAllDetails'><b>Assistant Secretary:</b> - / - </p><p class='teamAllDetails'><b>Home Colours:</b> Yellow</p><p class='teamAllDetails'><b>Away Colours:</b> Black</p><p class='teamAllDetails'><b>Home Venue:</b> Pallister Park</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#FFFFFF;'><div class='teamName'><p class='teamName'>Dormans FISC</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Alan Hodgeson - 01642123456 / - </p><p class='teamAllDetails'><b>Assistant Secretary:</b> - / - </p><p class='teamAllDetails'><b>Home Colours:</b> Red & Black</p><p class='teamAllDetails'><b>Away Colours:</b> Blue & White</p><p class='teamAllDetails'><b>Home Venue:</b> Acklam Sports Centre</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#E8E8E8;'><div class='teamName'><p class='teamName'>Marton Rovers</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Ged Anderson - 01642123456 / - </p><p class='teamAllDetails'><b>Assistant Secretary:</b> - / - </p><p class='teamAllDetails'><b>Home Colours:</b> Yellow & Blue</p><p class='teamAllDetails'><b>Away Colours:</b> White</p><p class='teamAllDetails'><b>Home Venue:</b> Pallister Park</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#FFFFFF;'><div class='teamName'><p class='teamName'>Marton Taxis</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Bryan Brown Coat - 01642123456 / - </p><p class='teamAllDetails'><b>Assistant Secretary:</b> - / - </p><p class='teamAllDetails'><b>Home Colours:</b> Yellow & Black</p><p class='teamAllDetails'><b>Away Colours:</b> White</p><p class='teamAllDetails'><b>Home Venue:</b> Pallister Park</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#E8E8E8;'><div class='teamName'><p class='teamName'>Ormesby FC</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Andy Mallaby - 01642123456 / - </p><p class='teamAllDetails'><b>Assistant Secretary:</b> - / - </p><p class='teamAllDetails'><b>Home Colours:</b> Green & White</p><p class='teamAllDetails'><b>Away Colours:</b> Red</p><p class='teamAllDetails'><b>Home Venue:</b> Eston Sports Academy</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#FFFFFF;'><div class='teamName'><p class='teamName'>Park End</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Old Steve - 01642 123456 / - steve.phelps@lsl.co.uk</p><p class='teamAllDetails'><b>Assistant Secretary:</b> Mr Lan - 01642 111000 / - mr.lan@hotmail.co.uk</p><p class='teamAllDetails'><b>Home Colours:</b> Navy & White</p><p class='teamAllDetails'><b>Away Colours:</b> White</p><p class='teamAllDetails'><b>Home Venue:</b> Ormesby Rd</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#E8E8E8;'><div class='teamName'><p class='teamName'>Roseberry Park</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Steve Coates - 01642123456 / - </p><p class='teamAllDetails'><b>Assistant Secretary:</b> - / - </p><p class='teamAllDetails'><b>Home Colours:</b> Green & White</p><p class='teamAllDetails'><b>Away Colours:</b> Blue & White</p><p class='teamAllDetails'><b>Home Venue:</b> Mill Hill</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#FFFFFF;'><div class='teamName'><p class='teamName'>South Bank</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Mr. Nice Guy - 01642123456 / - </p><p class='teamAllDetails'><b>Assistant Secretary:</b> - / - </p><p class='teamAllDetails'><b>Home Colours:</b> Red</p><p class='teamAllDetails'><b>Away Colours:</b> White</p><p class='teamAllDetails'><b>Home Venue:</b> South Bank</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#E8E8E8;'><div class='teamName'><p class='teamName'>The Black Swan</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Sean Thompson - 01642123456 / - </p><p class='teamAllDetails'><b>Assistant Secretary:</b> - / - </p><p class='teamAllDetails'><b>Home Colours:</b> Blue & Black</p><p class='teamAllDetails'><b>Away Colours:</b> White</p><p class='teamAllDetails'><b>Home Venue:</b> Prissick</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#FFFFFF;'><div class='teamName'><p class='teamName'>The Cleveland</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Ben Jamin - 01642123456 / - </p><p class='teamAllDetails'><b>Assistant Secretary:</b> - / - </p><p class='teamAllDetails'><b>Home Colours:</b> Blue & Black</p><p class='teamAllDetails'><b>Away Colours:</b> White</p><p class='teamAllDetails'><b>Home Venue:</b> Mill Hill</p><br /><br /></div></div><!--teamdetailrow end--><div style='background-color:#E8E8E8;'><div class='teamName'><p class='teamName'>Village Park Rangers</p></div><div class='teamAllDetails'><p class='teamAllDetails'><b>Team Secretary:</b> Gary Stonehouse - 01642123456 / - </p><p class='teamAllDetails'><b>Assistant Secretary:</b> - / - </p><p class='teamAllDetails'><b>Home Colours:</b> White & Black</p><p class='teamAllDetails'><b>Away Colours:</b> Yellow & Blue</p><p class='teamAllDetails'><b>Home Venue:</b> Mill Hill</p><br /><br /></div></div><!--teamdetailrow end--></div> </div><!--mainContent end--> <div id="leftSidebar"> <h2>Latest News!</h2> </div><!--sidebar end--> </div><!--contentArea end--> <div id="footer"> <p>© Langbaurgh Sunday League 2011</p> </div><!-- footer end--> </div><!--wrapper end--> </body> </html>
  9. How very strange.. If I have mine like that then it doesn't style the font, however when I put the class within in <p> tag it works. I wonder if the problem lies with extracting data from the database but I find that extremely hard to believe?
  10. I've sort of made progress. If I use #mainContent which is the entire surround ID around the whole of the content area then I can get the font-styling to work providing it is used as a paragraph class. If I stick div tags around the teamName without the paragraph class then refuses to style. Perhaps switching the quotes back to how you suggested may help.. /********** Team Contact Details **********/ #mainContent #teamDetails { width: 800px; margin:0 auto; background-color:#FFFFFF; font-family:Arial, Helvetica, sans-serif; } .teamDetailRow { width: 800px; margin:0 auto; } #mainContent .teamName { font-size:16px; }
  11. The problem is that no matter what styling I put in for the fonts within that div it just ignores them.. I can set margins, padding, background colours etc, but the font styling isn't working. I did try swapping single quotes with double, but that didn't seem to make a difference. Can't see what I am doing wrong here to be honest!
  12. Thanks TeNDoLLA, I have actually deduced that background colours are working fine. It is actually just the font styling which I can't get working. I have absolutely no problem with CSS at all, I just can't get it to integrate fully with my PHP code. Thanks for the pointers though, I've ammended that now.
  13. Hi, I might be being extremely dim, however, I can't for the life of me get certain aspects of the page to style despite putting a div around it. Anywhere where I have an echo statement with a div class or ID in it makes no difference to the output from the database. It's the first time I've done anything like this so I am learning as I am going along.. (note, anything not inside the php tags styles fine). Here is my code; <?php $pagetitle = "";?> <?php include("../includes/headerDivisions.php");?> <?php include("../includes/navigation.php");?> <?php include("../functions.php");?> <div id="contentArea"> <div id="mainContent"> <h1>Division 1 Team Contacts</h1> <br /> <br /> <?php // Make a MySQL Connection connectDatabase(); $sql="SELECT * FROM team"; $result=mysql_query($sql); //**********Basically this section that isn't styling at all where I am using echo followed by a div********** echo "<div id='teamDetails'>"; // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)){ echo "<div class='teamName'><p>",$rows[teamName],"</p></div>"; echo "<div class='teamInner'><p>Team Secretary: ",$rows[teamSecretary],"</p>"; echo "<p>Team Contact Number: ",$rows[teamContactNo],"</p>"; echo "<p>Team Colours Home: ",$rows[teamColoursHome],"</p>"; echo "<p>Team Colours Away: ",$rows[teamColoursAway],"</p>"; echo "<p>Team Pitch: ",$rows[teamPitch],"</p><br /><br /><hr></div>"; // close while loop } echo "</div>"; mysql_close(); ?> </div><!--mainContent end--> <?php include("../includes/sidebar.php");?> </div><!--contentArea end--> <?php include("../includes/footer.php");?> All help would be greatly appreciated. Many thanks.
  14. Seems like I posted too early! I was making a stupid mistake, when using the empty function I didn't pass it the correct values. I encased all processing/calculations within the following; if(!empty($teamAScore[$i]) || !empty($teamBScore[$i])) //This line is how I solved the problem*********************** { if(mysql_query($query)) echo "$i successfully updated results and league table.<br/><a href='div1Results.php'>Back to main page</a>"; //If fixtures update then update league table if ($teamAScore[$i] > $teamBScore[$i]) { //Team A update for team A win $teamAWin = "UPDATE division1 SET played=played+1, won=won+1, gf= gf+".$teamAScore[$i].", ga= ga+".$teamBScore[$i].", gd=gf-ga, pts= pts+3 WHERE teamID=$teamAID[$i]"; $resultTeamA = mysql_query($teamAWin) or die( "$teamAWin: " .mysql_error( ) ); //Team B update for teamB loss $teamBLoss = "UPDATE division1 SET played=played+1, lost=lost+1, gf=gf+".$teamBScore[$i].", ga=ga+".$teamAScore[$i].", gd=gf-ga WHERE teamID=$teamBID[$i]"; $resultTeamB = mysql_query($teamBLoss) or die( "$teamBLoss: " .mysql_error( ) ); } else if ($teamAScore[$i] < $teamBScore[$i]) { //Team A update for team A win $teamALoss = "UPDATE division1 SET played=played+1, lost=lost+1, gf=gf+".$teamAScore[$i].", ga=ga+".$teamBScore[$i].", gd=gf-ga WHERE teamID=$teamAID[$i]"; $resultTeamALoss = mysql_query($teamALoss) or die( "$teamAloss: " .mysql_error( ) ); //Team B update for teamB loss $teamBWin = "UPDATE division1 SET played=played+1, won =won+1, gf=gf+".$teamBScore[$i].", ga=ga+".$teamAScore[$i].", pts=pts+3, gd=gf-ga WHERE teamID=$teamBID[$i]"; $resultTeamBWin = mysql_query($teamBWin) or die( "$teamBWin: " .mysql_error( ) ); }else if ($teamAScore[$i] == $teamBScore[$i]) { //Team A update for team A win $teamADraw = "UPDATE division1 SET played=played+1, drawn=drawn+1, gf=gf+".$teamAScore[$i].", ga=ga+".$teamBScore[$i].", pts=pts+1, gd=gf-ga WHERE teamID=$teamAID[$i]"; $resultTeamADraw = mysql_query($teamADraw) or die( "$teamADraw: " .mysql_error( ) ); //Team B update for teamB loss $teamBDraw = "UPDATE division1 SET played=played+1, drawn=drawn+1, gf=gf+".$teamBScore[$i].", ga=ga+".$teamAScore[$i].", pts=pts+1, gd=gf-ga WHERE teamID=$teamBID[$i]"; $resultTeamBDraw = mysql_query($teamBDraw) or die( "$teamBDraw: sfsdsfsd " .mysql_error( ) ); } else echo "$i encountered an error.<br/>"; } }//Closes off the IF empty if statement*****************************
  15. Hi guys, I am trying to get my head around how to only insert data from a table when the data is entered. If the text field is empty then I don't want the data inserting. I have a result tables which shows all fixtures and the results in them. There is also a section within it at the bottom to deduct points from teams. In some cases the League do not always get results from every team and sometimes they don't get results for weeks. The way my existing page owrksi s that it will only ever insert if the boxes are filled in. When they are all filled in it works a treat. So my issue is that when there are a number of resultless fixtures how can I get them ignored by the PHP so that it doesn't try to insert them? I have tried a if not null then carry out the calculations but it still seems to be erroring... Please see my screenshot of the page and the update form that the page is linked to below; <?php $host="localhost"; // Host name $username="USERNAME"; // Mysql username $password="PWDFORDB"; // Mysql password $db_name="lsl"; // Database name $div1Table = "division1"; // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $submit = $_POST['submit']; $fixtureID = $_POST['fixtureID']; $teamAScore = $_POST['teamAScore']; $teamBScore = $_POST['teamBScore']; $teamAID = $_POST['teamAID']; $teamBID = $_POST['teamBID']; $pd = $_POST['pd']; $teamID = $_POST['teamID']; $limit = count($fixtureID); $deleteQRY = mysql_query("DELETE from division1")or die(mysql_error()); $selectTeamIDName = mysql_query("INSERT INTO division1 (teamID, teamName) SELECT teamID, teamName FROM team")or die(mysql_error()); for($i=0;$i<$limit;$i++) { $fixtureID[$i] = mysql_real_escape_string($fixtureID[$i]); $teamAScore[$i] = mysql_real_escape_string($teamAScore[$i]); $teamBScore[$i] = mysql_real_escape_string($teamBScore[$i]); $teamAID [$i] = mysql_real_escape_string($teamAID[$i]); $teamBID [$i] = mysql_real_escape_string($teamBID[$i]); $teamID [$i] = mysql_real_escape_string($teamID[$i]); $pd[$i] = mysql_real_escape_string($pd[$i]); $query = "UPDATE fixture SET teamAScore=$teamAScore[$i], teamBScore=$teamBScore[$i] WHERE fixtureID = $fixtureID[$i]"; if(mysql_query($query)) echo "$i successfully updated results and league table.<br/><a href='div1Results.php'>Back to main page</a>"; //If fixtures update then update league table if ($teamAScore[$i] > $teamBScore[$i]) { //Team A update for team A win $teamAWin = "UPDATE division1 SET played=played+1, won=won+1, gf= gf+".$teamAScore[$i].", ga= ga+".$teamBScore[$i].", gd=gf-ga, pts= pts+3 WHERE teamID=$teamAID[$i]"; $resultTeamA = mysql_query($teamAWin) or die( "$teamAWin: " .mysql_error( ) ); //Team B update for teamB loss $teamBLoss = "UPDATE division1 SET played=played+1, lost=lost+1, gf=gf+".$teamBScore[$i].", ga=ga+".$teamAScore[$i].", gd=gf-ga WHERE teamID=$teamBID[$i]"; $resultTeamB = mysql_query($teamBLoss) or die( "$teamBLoss: " .mysql_error( ) ); } else if ($teamAScore[$i] < $teamBScore[$i]) { //Team A update for team A win $teamALoss = "UPDATE division1 SET played=played+1, lost=lost+1, gf=gf+".$teamAScore[$i].", ga=ga+".$teamBScore[$i].", gd=gf-ga WHERE teamID=$teamAID[$i]"; $resultTeamALoss = mysql_query($teamALoss) or die( "$teamAloss: " .mysql_error( ) ); //Team B update for teamB loss $teamBWin = "UPDATE division1 SET played=played+1, won =won+1, gf=gf+".$teamBScore[$i].", ga=ga+".$teamAScore[$i].", pts=pts+3, gd=gf-ga WHERE teamID=$teamBID[$i]"; $resultTeamBWin = mysql_query($teamBWin) or die( "$teamBWin: " .mysql_error( ) ); }else if ($teamAScore[$i] == $teamBScore[$i]) { //Team A update for team A win $teamADraw = "UPDATE division1 SET played=played+1, drawn=drawn+1, gf=gf+".$teamAScore[$i].", ga=ga+".$teamBScore[$i].", pts=pts+1, gd=gf-ga WHERE teamID=$teamAID[$i]"; $resultTeamADraw = mysql_query($teamADraw) or die( "$teamADraw: " .mysql_error( ) ); //Team B update for teamB loss $teamBDraw = "UPDATE division1 SET played=played+1, drawn=drawn+1, gf=gf+".$teamBScore[$i].", ga=ga+".$teamAScore[$i].", pts=pts+1, gd=gf-ga WHERE teamID=$teamBID[$i]"; $resultTeamBDraw = mysql_query($teamBDraw) or die( "$teamBDraw: sfsdsfsd " .mysql_error( ) ); } else echo "$i encountered an error.<br/>"; } echo "<br /><br /><br /><br />"; $deductionLimit = count ($teamID); for($i=0;$i<$deductionLimit;$i++) { $teamID [$i] = mysql_real_escape_string($teamID[$i]); $pd[$i] = mysql_real_escape_string($pd[$i]); $queryDeduct = "UPDATE division1 SET pd=$pd[$i] WHERE teamID = $teamID[$i]"; if (mysql_query($queryDeduct)) echo "$i successfully deducted points.<br/><a href='div1Results.php'>Back to main page</a>"; if ($pd[$i] !=NULL) { $teamPointDeduction= "UPDATE division1 SET pts=pts-".$pd[$i]." WHERE teamID = $teamID[$i]"; $teamPointDeductionRun = mysql_query($teamPointDeduction) or die( "$pd: " .mysql_error( ) ); } else echo "Cannot update"; } // close connection mysql_close(); ?> Many thanks in advance!
×
×
  • 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.