Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
sending arrays via php to mysql
Old 09-14-2009, 03:50 PM sending arrays via php to mysql
Junior Talker

Posts: 2
Name: Colette
Trades: 0
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%'>&nbsp;BlueCross BlueShield</td>
<td width='25%'><input type=checkbox name=providers[1] value='HealthPartners'></td>
<td width='25%'>&nbsp;HealthPartners</td>
<td width='25%'><input type=checkbox name=providers[2] value='PreferredOne'></td>
<td width='25%'>&nbsp;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..
283Banfil is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-14-2009, 04:30 PM Re: sending arrays via php to mysql
Junior Talker

Posts: 2
Name: Colette
Trades: 0
I got it to work!! All by myself. Took me 2 days, but it works!!
283Banfil is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to sending arrays via php to mysql
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10219 seconds with 12 queries