|
Posted by William Stokes on 04/24/05 13:26
Hello,
I writing a script that allows user to update a soccer league table with web
form. I made a script that prints the old values to text fields in the form.
It's done with a loop so that each text field name is numbered +1 higher
than previous.
My problem is how to put the changed data back to the DB with a different
loop since the variable names chance for every team.
Here's the a sample of the update part( only one column to update). This
script gets 14 game and team values from form
like this; $new_games1,$new_games2,$new_games3,$new_games4 etc (and same for
the $team).
$sql="SELECT name FROM x_series WHERE team_type = 'series'";
$result=mysql_query($sql);
$rounds = mysql_num_rows($result);
$count = 1;
while ($rounds >= $count) {
$sql = "UPDATE x_series SET games = '$new_games1' WHERE name = '$team1'";
mysql_query($sql);
$count++;
}
So how can get the game and team variables to change (+1) each time the sql
query is fired? Or can I? Is the alternative to write 14 different sql
queries? Sounds stupid.
Hope someone gets my idea and can help. I've been banging my head against
the wall with this and I'm running out of fresh ideas. I really wouldn't
want to write those separate sql queries for each update if its possible to
avoid that. Thanks a lot.
-William
Navigation:
[Reply to this message]
|