I have a form where a users inputs goalscorers for each from a set of dropdown boxes. Any particular player can be selected more than one time (if they have scored multiple goals).
Everything works as desired, however, how can I program the below code to account for the fact the user may revisit the form and re-enter the stats? As you can see in the code it takes each posted player increments the goals for that game by 1. If a user decides they have done it wrong and wants to re-enter the information, the goal amount for the player will contain the old data PLUS the new data. I dont know how to distinguish if a user is re-entering info, as if a user has scored more than one goal it will have to update the field and increment the field by 1, so I cant say ON DUPLICATE "drop data".
Would the best way to do this just somehow block the user from revisiting the page once it is already entered (have a flag field in the database) and then create a seperate page they can to with the same code but drop all the data first?PHP Code:foreach($_POST["opthm$value"] as $idx => $player) {
$sqlinsertscorersh= ('INSERT into stats SET
match_id = \''.$_SESSION['gmid'.$value].'\',
player_id = \''.$player.'\',
goals=(goals+1)
ON DUPLICATE KEY UPDATE
match_id = \''.$_SESSION['gmid'.$value].'\',
player_id = \''.$player.'\',
goals=(goals+1)');
mysql_query($sqlinsertscorersh) or die(mysql_error()); }
foreach($_POST["optvis$value"] as $idx => $player) {
$sqlinsertscorersv= ('INSERT into stats SET
match_id = \''.$_SESSION['gmid'.$value].'\',
player_id = \''.$player.'\',
goals=(goals+1)
ON DUPLICATE KEY UPDATE
match_id = \''.$_SESSION['gmid'.$value].'\',
player_id = \''.$player.'\',
goals=(goals+1)');
mysql_query($sqlinsertscorersv) or die(mysql_error()); }





Bookmarks