echoed Posted April 3, 2009 Share Posted April 3, 2009 I'm Looking into using php and mysql for a hockey league statistics website for an online hockey game. I am and avid HTML coder, but have barely touched on php and want to learn how to be able to connect to a database and then display the information easily in a table format being able to sort by each category. ex. (http://www.nhl.com/ice/playerstats.htm?navid=NAV|STS|Indiv) Also, I would need to continually update the stats and would probably do so with forms and php? Quote Link to comment https://forums.phpfreaks.com/topic/152477-hockey-league-stats-management/ Share on other sites More sharing options...
Maq Posted April 3, 2009 Share Posted April 3, 2009 Also, I would need to continually update the stats and would probably do so with forms and php? Yes definitely, PHP would be a very good choice. Do you have anything set up? A basic tutorial on PHP/MySQL: [urlhttp://www.tizag.com/mysqlTutorial/]PHP/MySQL[/url]. Quote Link to comment https://forums.phpfreaks.com/topic/152477-hockey-league-stats-management/#findComment-800793 Share on other sites More sharing options...
echoed Posted April 4, 2009 Author Share Posted April 4, 2009 Thank you for the guide, once I get something up and tested I will report back here with what I have and what problems I have encountered. Quote Link to comment https://forums.phpfreaks.com/topic/152477-hockey-league-stats-management/#findComment-800957 Share on other sites More sharing options...
Maq Posted April 4, 2009 Share Posted April 4, 2009 Thank you for the guide, once I get something up and tested I will report back here with what I have and what problems I have encountered. Yes definitely do that. We have an excellent website critique section and a beta testing section as well in case you want to test some functionality and whatnot. Good luck Quote Link to comment https://forums.phpfreaks.com/topic/152477-hockey-league-stats-management/#findComment-800959 Share on other sites More sharing options...
echoed Posted April 5, 2009 Author Share Posted April 5, 2009 mysql_query("CREATE TABLE mklseason5( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), player VARCHAR(12), position INT, player_no INT, team VARCHAR(35), season_games_played INT, season_goals INT, season_assist INT, season_pts INT, season_gwg INT, playoff_games_played INT, playoff_goals INT, playoff_assist INT, playoff_pts INT, playoff_gwg INT)") or die(mysql_error()); So i created that table. I need to know how would i be able to insert data into those tables with forms. Link to the form-http://mkl-stats.co.cc/admin/insertdata.php I have no idea how to code "process.php" that I used to process the form. Also, how would i get "season_pts" to calculate by adding "season_goals" and "season_assist" together. Quote Link to comment https://forums.phpfreaks.com/topic/152477-hockey-league-stats-management/#findComment-801782 Share on other sites More sharing options...
revraz Posted April 5, 2009 Share Posted April 5, 2009 Google or search for "PHP Forms MySQL Tutorial" You should get some hits there. Quote Link to comment https://forums.phpfreaks.com/topic/152477-hockey-league-stats-management/#findComment-801788 Share on other sites More sharing options...
Gem Posted April 5, 2009 Share Posted April 5, 2009 Hi Try something like this for your process.php file.. Change the connection details, database name, tablename and add the rest of the values (Where I put ETC ETC ... sorry, I was being lazy) Hope that help a little bit Gem <?php $con = mysql_connect("HOST","USER","PASSWORD"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("DATABASE NAME", $con);$sql="INSERT INTO tablename (player, position, player_no, team, ETC ETC) VALUES ('$_POST[player]', '$_POST[position]', '$_POST[player_no]'), ETC ETC"; if (!mysql_query($sql,$con)) { die('Error: ' . " $sql " . mysql_error()); } echo "1 record added";mysql_close($con) ?> Quote Link to comment https://forums.phpfreaks.com/topic/152477-hockey-league-stats-management/#findComment-801798 Share on other sites More sharing options...
echoed Posted April 5, 2009 Author Share Posted April 5, 2009 editing code Quote Link to comment https://forums.phpfreaks.com/topic/152477-hockey-league-stats-management/#findComment-801810 Share on other sites More sharing options...
echoed Posted April 6, 2009 Author Share Posted April 6, 2009 http://mkl-stats.co.cc/ Need to know how to get $ppg to round to 2 decimal points. <?php $no = 0; $result = mysql_query("SELECT * FROM `mklseason5` ORDER BY `mklseason5`.`season_goals` DESC") or die(mysql_error()); echo "<table border='1' align='center'>"; echo "<tr><th>No.</th> <th>Player</th> <th>Pos.</th><th>Team</th><th>GP</th><th>G</th><th>A</th><th>PTS</th><th>GWG</th><th>PPG</th></tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { $no++; $ppg = $row['season_pts']/$row['season_games_played']; // Print out the contents of each row into a table echo "<tr><td>"; echo $no; echo "</td><td>"; echo $row['player']. "(#". $row['player_no'] . ")"; echo "</td><td width='50'>"; echo $row['position']; echo "</td><td align='center'>"; echo $row['team']; echo "</td><td>"; echo $row['season_games_played']; echo "</td><td>"; echo $row['season_goals']; echo "</td><td>"; echo $row['season_assist']; echo "</td><td>"; echo $row['season_pts']; echo "</td><td>"; echo $row['season_gwg']; echo "</td><td>"; echo $ppg; echo "</td></tr>"; } Edit: found out echo round($ppg,2); Quote Link to comment https://forums.phpfreaks.com/topic/152477-hockey-league-stats-management/#findComment-802012 Share on other sites More sharing options...
Fruct0se Posted April 6, 2009 Share Posted April 6, 2009 round($ppg, 2) Quote Link to comment https://forums.phpfreaks.com/topic/152477-hockey-league-stats-management/#findComment-802014 Share on other sites More sharing options...
echoed Posted April 6, 2009 Author Share Posted April 6, 2009 On my admin page i want to be able to update my database by clicking on a + or - next to the stat that i want to edit. My admin update page would look like http://mkl-stats.co.cc/statistics/index.php but each to next number it would have a [+ or -] which you would click to add or subtract and then update the database. Quote Link to comment https://forums.phpfreaks.com/topic/152477-hockey-league-stats-management/#findComment-802878 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.