here is th ecurrent code
<?php
mysql_connect("localhost", "root", "root") or die(mysql_error());
mysql_select_db("test_game") or die(mysql_error());
//error_reporting(E_ALL);
error_reporting(0);
?>
<?php
$query = "SELECT player_name, hit_points FROM users";
$result=mysql_query($query);
while ($row = mysql_fetch_assoc($result))
{
$player_name = $row['player_name'];
$hit_points = $row['hit_points'];
if($hit_points <= "0")
{
echo "$player_name is dead                  ";
}
else
{
echo "Player: $player_name ";
echo "Hit points: $hit_points         ";
}
}
?>
<title>test game</title>
</head>
<body>
<br><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="FormName"><input name="hit_player_2" type="submit" value="hit_player_2">
                           <input name="hit_player_1" type="submit" value="hit_player_1"></form>
<?php
if(isset($_POST['hit_player_1'])){
$sql = "UPDATE users SET hit_points=hit_points-1 WHERE player_name = 'player_1'";
mysql_query($sql)or die(mysql_error());
}
if(isset($_POST['hit_player_2'])){
$sql = "UPDATE users SET hit_points=hit_points-1 WHERE player_name = 'player_2'";
mysql_query($sql)or die(mysql_error());
}
?>
</body>
</html>
The problem i have now is when I click "hit_player_2" it first takes away a point from player one. If I continue to click "hit_player_2" it will then take away points from player 2. "Hit_player_1" does th same thing. I also noticed that it takes away a point from the last player to lose one when I manually refresh.