Jump to content

Help With An Update Statement


dzhax

Recommended Posts

I am working on a project that keeps track of someones professional record. I have a table with fields like so

id	 name	 ko_wins	 ko_loss	 tko_wins	 tko_loss	 decission_wins	 decission_loss	 draws

I was hoping on making an update statement that could increment the proper field + 1 when new fight data comes in Like: UPDATE fighter_stats SET ko_wins = +1 WHERE name = FIGHTERNAMEHERE; Not sure how to do it and i can not figure out how or if it is even possible. Any help is appreciated.

Link to comment
Share on other sites

thanks for the prompt response. Maybe it needs to be different if i am using it with php? I tried that code and it doesn't appear to work.

<?    include('lib/sql.dat');    $connection = mysql_connect($server,$username,$password) or die('unable to connect');    mysql_select_db($database,$connection);       if (($_GET['status'] == 'Official') or ($_GET['status'] == 'NSF')){                $tko = strpos($_GET['winningMethod'],'TKO');        if($tko === true) {             // TKO found in winningMethod             $fightWinner = $_GET['winner'];             $fName1 = $_GET['fighter1'];             $fName2 = $_GET['fighter2'];             $method = 'TKO';                          if($fightWinner == '1'){                 $sql = "UPDATE `rank_fighter_stats` SET `t_wins` = t_wins+1 WHERE `DisplayName` = '" . $fName1 . "'";                 mysql_query($sql, $connection);                 $sql = "UPDATE `rank_fighter_stats` SET `t_losses` = t_losses+1 WHERE `DisplayName` = '" . $fName2 . "'";                 mysql_query($sql, $connection);             } elseif ($fightWinner == '2') {                 $sql = "UPDATE `rank_fighter_stats` SET `t_wins` = t_wins+1 WHERE `DisplayName` = '" . $fName2 . "'";                 mysql_query($sql, $connection);                 $sql = "UPDATE `rank_fighter_stats` SET `t_losses` = t_losses+1 WHERE `DisplayName` = '" . $fName1 . "'";                 mysql_query($sql, $connection);             } else {                 $sql = "UPDATE `rank_fighter_stats` SET `draws` = draws+1 WHERE `DisplayName` = '" . $fName2 . "'";                 mysql_query($sql, $connection);                 $sql = "UPDATE `rank_fighter_stats` SET `draws` = draws+1 WHERE `DisplayName` = '" . $fName1 . "'";                 mysql_query($sql, $connection);             }        } else {             // TKO NOT found in winningMethod        }    }    mysql_close($connection);?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...