|
I'm stumped. I've been at this for days!! Huh
I'm trying to pass an array via checkboxes, using php and mysql. I have the following 2 pages, can someone please tell me what I've got wrong. I can pass the array to the second page, and have it echo(print) correctly, but when it gets to the database, it will only give me the last choice. I also can get it to post "array" to the database, but I don't want that either!!
Insert form:
<?php
echo "<form method=post action='form3.php'>";
echo "<table border='0' cellspacing='0' style='border-collapse: collapse' width='100' >
<tr bgcolor='#ffffff'>
<td width='25%'><input type=checkbox name=providers[0] value='BlueCross BlueShield'></td>
<td width='25%'> BlueCross BlueShield</td>
<td width='25%'><input type=checkbox name=providers[1] value='HealthPartners'></td>
<td width='25%'> HealthPartners</td>
<td width='25%'><input type=checkbox name=providers[2] value='PreferredOne'></td>
<td width='25%'> PreferredOne</td>
</tr>
<tr><td colspan =6 align=center><input type=submit value=Select></form></td></tr>
</table>"; ?>
Results Action page
<?php
$providers=$_POST['providers'];
while (list ($key,$val) = each ($providers)) {
echo "$val,\n";
$mysql="INSERT INTO oe.hsa SET
providers='$val'";}
if (mysql_query($mysql)) {
echo 'New Registration added';
} else {
echo mysql_error();
}
?>
Last edited by 283Banfil; 09-14-2009 at 03:52 PM..
|