MWG_Thomas Posted April 16, 2008 Share Posted April 16, 2008 Ok Hey guys, Basically I cant get the following code to work: $sql="SELECT Player_id,Team_id,Name FROM players WHERE Team_id=$team1 ORDER BY Player_id"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $sql2 = "UPDATE players SET Goals=Goals+'$_POST['$row{'Player_id'}.'_score']', Assists=Assits+'$_POST['$row{'Player_id'}.'_assist']' WHERE id= $row{'Player_id'}" ; echo $sql2; echo "<p>"; if (mysql_query($sql2)) { print "successfully inserted record"; } else { print "Failed to insert record"; } } Im fairly sure the problem is with the $_POST['$row{'Player_id'}.'_assist'] I use the following code in my form to generate the variables i am trying to get: echo "<h4>Team 1 scorers </H4>"; $sql="SELECT Player_id,Team_id,Name FROM players WHERE Team_id=$team1 ORDER BY Player_id"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { echo '<b>'.$row{'Name'}.'</b> <br>Scored: <input type="text" name="'.$row{'Player_id'}.'_score" size=5 maxlength=5> Assisted: <input type="text" name="'.$row{'Player_id'}.'_assist" size=5 maxlength=5><p>'; } I think this bit works right, however I cant work out how to read them out on the process page! I hope that makes sense, Thanks for any help you can offer! Tom Link to comment https://forums.phpfreaks.com/topic/101293-using-post-and-mysql/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.