From form to db question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux