Jump to content

ade2901

Members
  • Posts

    30
  • Joined

  • Last visited

Everything posted by ade2901

  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!
  16. I think I am spending too much time looking at my code! That solved it! I never noticed it myself haha! Thanks a lot for pointing that out, extremely helpful.
  17. Hi all, I have a form which allows the end user to input results of football games. When they do this the league table is updated. I have everything working correctly apart from one team that consistently doesn't work. It adds up everything correctly apart from gf (goals for) and ga (goals against). The team that is problematic is 'The Southfield'. If for example they won 2-0 in fixtureID 19 and then 3-0 in fixtureID 20, their goals for and goals against would remain at 0, yet their points, won, drawn and lost values would be 100% correct... See below for the code used to determine the league table; <?php $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $div1Table = ""; // 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']; $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]); $query = "UPDATE fixture SET teamAScore=$teamAScore[$i], teamBScore=$teamBScore[$i] WHERE fixtureID = $fixtureID[$i]"; if(mysql_query($query)) echo "$i successfully updated.<br/><a href='div1Results.php'>Back to main page</a>"; //If fixtures update then update league table //UPDATING OF LEAGUE TABLE TAKES PLACE HERE************************************************ 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].", 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]." 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]." 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 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 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=".$teamBScore[$i].", ga=".$teamAScore[$i].", pts=pts+1 WHERE teamID=$teamBID[$i]"; $resultTeamBDraw = mysql_query($teamBDraw) or die( "$teamBDraw: " .mysql_error( ) ); } else echo "$i encountered an error.<br/>"; } // close connection mysql_close(); ?> All help as to why the gf and ga columns aren't working for one specific team would be much appreciated. Thanks in advance, Aidan
  18. Ah yes, that was a schoolboy mistake! Thanks for pointing that out, can't believe I missed it. I'll alter that straight away when I get back to my machine. Strange what you do when you've looked at it for too long! Thanks, I appreciate both of you pointing that out. Fingers crossed it'll work now and update the league table correctly.
  19. Oh dear, initially when writing this reply I said yes however on second thought I don't need the counter value passed to it do I? But then how does it determine which teamID it is referring to as it'll change per fixture and that php is linked to a form with multiple fixtures. I can't try it at this moment in time as I'm not at home any longer.
  20. Hi all, I have a bit of an issue. I have a page that allows the user ot input the results/scores of football fixtures (currently there are 6 fixtures displayed). When the user clicks submit it then updates the results fine. I then want it to update the league table, however, I keep getting the following error: 0 successfully updated. Back to main page UPDATE division1 SET played=played+1, draw=draw+1, gf=1, ga=1, pts=pts+1 WHERE teamID=teamAID[0]: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[0]' at line 1. This shows that it only updated the first record rather than all of the fixtures (as it's supposed to) showing it has just stopped going through the loop after the first result, despite the score entered being 2:1 to the home team therefore it shouldn't be checking the draw query. I'll now show you my code (see below comment reading; /PROBLEMS OCCURING HERE WHEN UPDATING LEAGUE TABLE*********); <?php $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name=""; // Table 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"); $submit = $_POST['submit']; $fixtureID = $_POST['fixtureID']; $teamAScore = $_POST['teamAScore']; $teamBScore = $_POST['teamBScore']; $teamAID = $_POST['teamAID']; $teamBID = $_POST['teamBID']; $limit = count($fixtureID); 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]); $query = "UPDATE fixture SET teamAScore=$teamAScore[$i], teamBScore=$teamBScore[$i] WHERE fixtureID = $fixtureID[$i]"; if(mysql_query($query)) echo "$i successfully updated.<br/><a href='div1Results.php'>Back to main page</a>"; //If fixtures update then update league table //PROBLEMS OCCURING HERE WHEN UPDATING 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=".$teamAScore[$i].", ga=".$teamBScore[$i].", 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=".$teamBScore[$i].", ga=".$teamAScore[$i]." WHERE teamID=teamBID[$i]"; $resultTeamB = mysql_query($teamBLoss) or die( "$teamBLoss: " .mysql_error( ) ); } if ($teamAScore[$i] < $teamBScore[$i]) { //Team A update for team A win $teamALoss = "UPDATE division1 SET played=played+1, lost=lost+1, gf=".$teamAScore[$i].", ga=".$teamBScore[$i]." 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=".$teamBScore[$i].", ga=".$teamAScore[$i].", pts=pts+3 WHERE teamID=teamBID[$i]"; $resultTeamBWin = mysql_query($teamBWin) or die( "$teamBWin: " .mysql_error( ) ); } if ($teamAScore[$i] == $teamBScore[$i]) { //Team A update for team A win $teamADraw = "UPDATE division1 SET played=played+1, draw=draw+1, gf=".$teamAScore[$i].", ga=".$teamBScore[$i].", pts=pts+1 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, draw=draw+1, gf=".$teamBScore[$i].", ga=".$teamAScore[$i].", pts=pts+1 WHERE teamID=teamBID[$i]"; $resultTeamBDraw = mysql_query($teamBDraw) or die( "$teamBDraw: " .mysql_error( ) ); } else echo "$i encountered an error.<br/>"; } // close connection mysql_close(); ?> All help would be much appreciated as I am really stuck here! Any questions about my problem please just ask. Many thanks in advance, Aidan
  21. It turns out it was I made no attempt to relate it to the fixtureID. Further to this I separeted the submit processing into a new file. I'll post the solution for anyone else who may have this problem. Page to display all fixtures for the teams linking up the team name to the team id through a join query. <?php // Make a MySQL Connection mysql_connect("localhost", "yourUsername", "yourPassword") or die(mysql_error()); mysql_select_db("yourDatabase") or die(mysql_error()); //Query to join tables and obtain team names linked to IDs $sql2= mysql_query ("SELECT *, fixtureVenue, t.TeamName as teamA, tt.TeamName as teamB from team t inner join fixture f on f.teamA = t.teamid inner join team tt on f.teamB = tt.teamid")or die(mysql_error()); //DO THE ABOVE BUT FOR UPDATE echo "<table border='1' width='500' >"; echo "<form name='form1' method='post' action='php_insert_result.php'>"; echo "<tr> <th>ID</th><th>Team 1</th> <th>Score</th> <th> - </th> <th>Score</th> <th>Team 2</th> <th>Date</th></tr>"; while($row = mysql_fetch_array($sql2) ) { // Print out the contents of each row i echo "<tr><td>"; echo "<input type='text' name='fixtureID[]' id='fixtureID[]' size='2' value='",$row['fixtureID'],"'/>"; echo "</td>"; echo "<td>"; echo $row['teamA'] ; echo "</td><td>"; echo "<input type='text' name='teamAScore[]' size='1' value='",$row['teamAScore'],"' />"; echo "</td><td>"; echo " - "; echo "</td><td>"; echo "<input type='text' name='teamBScore[]' size='1' value='",$row['teamBScore'],"' />"; echo "</td><td>"; echo $row['teamB']; echo "</td><td>"; echo $row['fixtureDay'], " ", $row['fixtureMonth']," ",$row['fixtureYear'] ; echo "</td>"; echo "</tr>"; } echo "<tr><input type='submit' value='Submit' name='Submit'/></tr>"; echo"</form>"; echo "</table>"; mysql_close(); ?> The updatefile linked to the form with the update statment refering to the fixtureID. <?php $host="localhost"; // Host name $username="yourUsernameHere"; // Mysql username $password="yourPasswordHere"; // Mysql password $db_name="lsl"; // 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"); $submit = $_POST['submit']; $fixtureID = $_POST['fixtureID']; $teamAScore = $_POST['teamAScore']; $teamBScore = $_POST['teamBScore']; $limit = count($fixtureID); 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]); $query = "UPDATE fixture SET teamAScore=$teamAScore[$i], teamBScore=$teamBScore[$i] WHERE fixtureID = $fixtureID[$i]"; if(mysql_query($query)) echo "$i successfully updated.<br/><a href='div1Results.php'>Back to main page</a>"; else echo "$i encountered an error.<br/>"; } // close connection mysql_close(); ?> Hope this helps others! I now need to get my head around how to update teams details (points, goals scored, goals conceded, games won, games lost, games drawn etc) in the table division1 which is a league table and link the teams through their IDs.. If anyone has any suggestions for this then I'd appreciate that. Otherwise I'll start a new thread with full details of the table structure etc to make it easier. Yet another part I am stuck on! Thanks for the help, Aidan
  22. I've noticed that my select query isn't working so until I get that sorted my update query won't. Despite the correct output from the select query the join doesn't seem to have worked as I would have thought.
  23. Since thinking I had solved it I clearly haven't! I had the teamIDs output with the teamNames after having issues with updating and it appears as though each team in one row share the same ID.. E.g. FixtureID | teamName teamID | teamAScore | teamBScore | teamB teamBScore 19 The Southfield4 0 - 0 Teal Arms4 The Southfield is actually ID number 1 and Team Arms are ID number 4... Does anyone have an idea why this is happening despite the table join?
  24. I have tried seeing what error is occuring and there are none. It's submitting and doing nothing. It mustn't be entering the if statement for the submit button..
  25. Hi, I have a list of fixtures displayed from the database with input fields for the scores so that the user can insert them. I am having a problem updating it and linking it to the IDs, this is obviously done in the WHERE clause but I don't know quite what to pass it. I have a query to join the fixture and team table so that the teamID can be linked to the teamName. I now need to update the data in the fixtures table based on the teamID not name as the teams are stored as their IDs in the fixture table and not their names. You can see my code below; <?php // Make a MySQL Connection mysql_connect("localhost", "admin", "admin") or die(mysql_error()); mysql_select_db("lsl") or die(mysql_error()); //Query to join tables and obtain team names linked to IDs $sql2= mysql_query ("SELECT *, fixtureVenue, t.TeamName as teamA, tt.TeamName as teamB from team t inner join fixture f on f.teamA = t.teamid inner join team tt on f.teamB = tt.teamid ORDER BY fixtureday,fixturemonth,fixtureyear")or die(mysql_error()); echo "<table border='1' width='500'>"; echo "<form name='form1' method='post'>"; echo "<tr> <th>Team 1</th> <th>Score</th> <th> - </th> <th>Score</th> <th>Team 2</th> <th>Date</th></tr>"; while($row = mysql_fetch_array($sql2) ) { // Print out the contents of each row i echo "<tr><td>"; echo $row['teamA']; echo "</td><td>"; echo "<input type='text' name='teamAScore[]' size='1' />"; echo "</td><td>"; echo " - "; echo "</td><td>"; echo "<input type='text' name='teamBScore[]' size='1' />"; echo "</td><td>"; echo $row['teamB']; echo "</td><td>"; echo $row['fixtureDay'], " ", $row['fixtureMonth']," ",$row['fixtureYear'] ; echo "</td>"; echo "</tr>"; } echo"<input type='submit' value='Submit Results' name='submit'/>"; echo"</form>"; echo "</table>"; //THIS IS WHERE I AM HAVING THE TROUBLE. It just doesn't update whatsoever. I know my WHERE clause is wrong but not sure how to combat it or what to search for to get help.. if($Submit){ for($i=0;$i<$count;$i++){ $sql1="UPDATE fixture SET teamAScore='$teamAScore[$i]', teamBScore='$teamBScore[$i]' WHERE teamA = teamID and teamB = teamID"; $result1=mysql_query($sql1); } } if($result1){ echo "Updated!"; } mysql_close(); ?> All help would be extremely appreciated! Any questions please don't hesitate to ask. Many thanks in advance, Aidan
×
×
  • 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.