Jump to content

array problem


Gaia

Recommended Posts

Hi,

I have a form that is submitting multiple checkboxes, which when submitted turns into an array.

So my $_POST['option'] turns into a foreach.

[code]
<?php

$options = $_POST['option'];

foreach ( $options AS $foo ) {

        $new_options .= 'Something: '.$foo.' &nbsp;';
}

?>
[/code]

The probem is when i submit it to a database the word Array gets stuck to the first option. so say the $options resulted in 3 check boxes being marked, option1, option2, and option3.

The output would be...

ArraySometing: option1 Something: option2 Something: option3

How do i fix that?

Thanks.
Link to comment
Share on other sites

$options is an array?


Do something like:
[code]
<?php

// do a loop on this, most likely...
$options[0] = $_POST['option1'];
$options[1] = $_POST['option2'];


// get the values and store as a string.
foreach ( $options AS $key=>$value )
{
        $new_options .= 'Something: '.$value.' &nbsp;';
}

?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.