I have a form that get from mysql
"index.php"
echo "<form method=\"POST\" action=\"do_arrm.php\">";
echo "<TABLE ALIGN=\"CENTER\" CELLPADDING=\"3\" WIDTH=\"100 %\" BORDER=\"0\">";
echo "<TR>
<TH>ID</TH>
<TH>First Name</TH>
<TH>spouse</TH>
<TH>Last Name</TH>
<TH>Phone Number</TH>
<TH>H-BDay</TH>
</TR>";
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$fname = $row['fname'];
$spouse = $row['spouse'];
$lname = $row['lname'];
$phonenumber = $row['phonenumber'];
$presenter = $row['presenter'];
$b_hbday = $row['b_hbday'];
$b_wbday = $row['b_wbday'];
$b_anniversary = $row['b_anniversary'];
$holiday = $row['holiday'];
$newsletter = $row['newsletter'];
echo "<TR ALIGN=\"CENTER\">
<TD >$id<input type=\"hidden\" value=\"$row[id]\"
name=\"id[$i]\"></TD>
<TD>$fname</TD>
<TD>$spouse</TD>
<TD>$lname</TD>
<TD>$phonenumber</TD>
<TD<input type=\"checkbox\" name=\"b_hbday\" value=\"Y\"";
if ($b_hbday == "Y"){
echo "CHECKED";
}
echo ">
</font></TD>
</TR>
";
}
echo "</TABLE>";
echo "<p align=\"center\"><input type=\"submit\" value=\"Submit\" name=\"B1\"><input type=\"reset\" value=\"Reset\" name=\"B2\"></p>";
echo "</form>";
What i want to have happen here is that when you click the submit button it updates mysql whith the new checkbok information.
"do_arrm.php"
<?
// connect to db
$connection = @mysql_connect("localhost", "username", "pass") or die("Couldn't connect.");
$db = @mysql_select_db(db_name, $connection) or die("Couldn't select database.");
while (list($key,$val) = each($HTTP_POST_VARS)) {
$$Key = $val;
if (is_array($val)) {
for ($i=0; $i<count($val); $i++) {
$content .= "$key: $val[$i]\n";
$sql = "UPDATE customers
SET
b_hbday = \"$b_hbday\"
WHERE id = \"$id\"
";
$result = @($sql,$connection) or die("Couldn't execute query.");
next ($val);
}
}
} else {
$content .= "$key: $val\n";
}
}
print nl2br($content); //or mail...
?>
What am I doing wrong?