Jump to content

Hockey League Stats Management


echoed

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/152477-hockey-league-stats-management/
Share on other sites

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].

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  ;)

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.

 

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)
?>

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);

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.

 

 

 

 

Archived

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

×
×
  • 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.