Forum Moderators: coopster

Message Too Old, No Replies

Using Checkboxes to INSERT INTO

won't insert into second table

         

mooger35

9:02 pm on Mar 21, 2006 (gmt 0)

10+ Year Member



This is the code I have on my action form.

foreach($_POST['playerid'] as $key => $playerid) {
$sql = "INSERT INTO stats VALUES(NULL, '".$_POST['playerid'][$key]."', '".$_POST['year']."', '0', '0', '0', '0')";
}
foreach($_POST['goalie'] as $key2 => $goalie) {
$sql2 = "INSERT INTO goalies VALUES(NULL, '".$_POST['goalie'][$key2]."', '".$_POST['year']."', '0', '0', '0', '0', '0', '0', '0')";
}

This is the form output

Array
(
[playerid] => Array
(
[0] => 8
[1] => 18
)

[goalie] => Array
(
[0] => 18
)

[year] => 200607
)

I can't seem to get them to update. It worked before I added the second table insert. I've fiddled with it so there may be a couple new errors now. But any help would be nice! Thanks.

mooger35

9:40 pm on Mar 21, 2006 (gmt 0)

10+ Year Member



nevermind...

forgot: $results_player = mysql_query($sql);

and the corresponding one for $sql2