Jump to content

echoed

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

echoed's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Can't believe i missed that ...-.- Thanks a million.
  2. doesn't help much! does it run the query? try changing value="+" and value="-" to value="add" Nope, the query doesn't run.
  3. <?php $player = $_POST['player']; $conn=mysql_connect("****","**********","********"); mysql_select_db("******"); if(isset($_POST['g_add'])){ $query="UPDATE `mklseason5` SET `season_goals` = `season_goals`+1 WHERE `player` = `$player`"; mysql_query($query) or die("Cannot add"); echo "succesfully added goal from ". $player; } if(isset($_POST['g_subtract'])){ $query="UPDATE `mklseason5` SET `season_goals` = `season_goals`-1 WHERE `player` = `$player`"; mysql_query($query) or die("Cannot subtract"); echo "succesfully subtracted goal from ". $player; } ?> Also tried Ashoar's advice and it doesn't work.
  4. Well when i click on the + or - the or die("Cannot add"); or or die("Cannot subtract"); is displayed on the page.
  5. On my administration page i want to be able to easily update hockey statistics and such ,this is just a small example portion of what the page will be but after i get this to work i should be able to finish the rest. When i click on the + or - i want it to Update the goals and either add or subtract 1 to the entry. My Form <html> <body> <form name="form" method="post" action="process_update_player.php"> Player: <input type="text" name="player"><br /> Goals<input type="submit" name="g_add" value="+"><input type="submit" name="g_subtract" value="-"><br> </form> </body> </html> My php code(process_update_player.php) <?php $player = $_POST['player']; $add = 1; $subtract = 1; $conn=mysql_connect("localhost","****","********"); mysql_select_db("***********"); if(isset($_POST['g_add'])){ $query="UPDATE `mklseason5` SET `season_goals` += `$add` WHERE `player` = `$player`"; mysql_query($query) or die("Cannot add"); echo "succesfully added goal to ". $player; } if(isset($_POST['g_subtract'])){ $query="UPDATE `mklseason5` SET `season_goals` -= `$subtract` WHERE `player` = `$player`"; mysql_query($query) or die("Cannot subtract"); echo "succesfully subtracted goal to ". $player; } ?>
  6. 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.
  7. 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);
  8. 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.
  9. 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.
  10. 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?
×
×
  • 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.