Hi I had searched a lot on this site for help, but more I search more I'm confused.
I have one table competition where there is field ID(primary key) Player *TeamName*(3 players in a team) and Score(players)
competition TeamCompetition
Player : TeamName : Score : TeamName : TeamScore
------ : -------- : ----- : ----------------------
Tom : team1 : 50 : team1 : 50+66+35=151
Brian : team1 : 66 : team2 : 54+85+...etc
Tim : team1 : 35 :
Calvin : team2 : 54 :
Jerry : team2 : 85 :
etc.
I have managed to make SUM in SQL Like so:
$result1 = mysql_query("SELECT SUM(Score) AS team1 FROM competition WHERE TeamName='team1' ");
I tried to save that variable $team1 to new table called TeamCompetition and where sum of one team is saved like one number with name of a team
$row1= mysql_fetch_array($result1);
$team1= $row1['team1'];
$sql1=("INSERT INTO TeamCompetition (TeamScore)
VALUES '$_POST[team1]'
WHERE TeamName='team1' ");
But that wont work, can anybody suggest me how to deal with this code, OR is there another more eleganth way to solve it? If I echo it without $sql1 it shows result why can't I save it...?