Need help with looping
Posted: Sat Jan 07, 2006 11:56 pm
Hey guys,
I'm working on a form to keep track of player stats. The problem I'm having is once the form is submitted; only the "lowest" number "user_id" stats are updated. I've been chasing my tail on this thing for two solid days. Any help would be greatly appreciated.
Thanks in advance,
Nick
The following is a copy of the results. I have no idea where the "1" is coming from?
I'm working on a form to keep track of player stats. The problem I'm having is once the form is submitted; only the "lowest" number "user_id" stats are updated. I've been chasing my tail on this thing for two solid days. Any help would be greatly appreciated.
Thanks in advance,
Nick
Code: Select all
<?php
if ($_POST['action'] == "update") {
$user_id = $_POST['user_id'];
$total_wins = $_POST['total_wins'];
$total_losses = $_POST['total_losses'];
$total_score = $_POST['total_score'];
$sql = mysql_query("update phpbb_pool set total_wins='$total_wins', total_losses='$total_losses', total_score='$total_score' where user_id = $user_id");
echo ("$sql");
}
?>
<form action="<?php echo "{$_SERVER['PHP_SELF']}"; ?>" method="post">
<input type="hidden" name="action" value="update">
<table name='scores' width='50%' cellpadding='3' cellspacing='1' border='0' class='forumline' align='center'>
<tr>
<th height='25' class='thCornerL' nowrap>Username</th>
<th class='thTop' nowrap>Wins</th>
<th class='thTop' nowrap>Losses</th>
<th class='thCornerR' nowrap>Total Score</th>
</tr>
<?php
$query = mysql_query("select phpbb_pool.user_id, phpbb_users.user_id, username, total_wins, total_losses, total_score from phpbb_pool, phpbb_users where (phpbb_pool.user_id=phpbb_users.user_id) order by username asc");
while ($row = mysql_fetch_array($query)) {
$user_id = $row["user_id"];
$username = $row["username"];
$total_wins = $row["total_wins"];
$total_losses = $row["total_losses"];
$total_score = $row["total_score"];
echo"<input type='hidden' name='user_id' value='$user_id'>";
echo"<tr>";
echo"<td class='row1' align='center'><span class='gen'>$username</span></td>";
echo"<td class='row1' align='center'><span class='gen'><input type='text' name='total_wins' size='3' value='$total_wins'></span></td>";
echo"<td class='row1' align='center'><span class='gen'><input type='text' name='total_losses' size='3' value='$total_losses'></span></td>";
echo"<td class='row1' align='center'><span class='gen'><input type='text' name='total_score' size='3' value='$total_score'></span></td>";
echo"</tr>";
}
?>
<tr><td class='row1' colspan='4' align='center'><br><input type="submit" name="update" class="liteoption" value="Update"></td></tr>
</table>
</form>Code: Select all
user_id=3
total_wins=20
total_losses=5
total_score=15
1