Hi Master,

please help me, i could not insert my multiple checkbox selected value into my table. please see and help me.
its insert only one value like first one. here is code:

**HTML code: **

<td width="75%">
<input type="checkbox" name="whats_include[]"  value="Breakfast" > Breakfast / 
<input type="checkbox" name="whats_include[]"   value="Lunch" > Lunch / 
<input type="checkbox" name="whats_include[]" value="Dinner" > Dinner /
<input type="checkbox" name="whats_include[]"  value="Drink" > Drink /
<input type="checkbox" name="whats_include[]"  value="Transport" > Transport 
</td>

PHP Value Insert Code

if($_POST)
    {
        $per = $_POST['whats_include'];    
        foreach($per as $p) {
          $inclues=  $p.',';
          $data['whats_include'] = $inclues;
         dumpVar($data);
        }
        insert(tbl_new_package, $data)   //insert query (table, $data)//
    }

Output:

Array
(
    [user_id] => 1
    [trip_name] => bangla tour
    [tour_type] => none
    [day] => 
    [nights] => 
    [service_level] => ---None---
    [min_person] => 0
    [max_person] => 1
    [whats_include] => Breakfast,
)

here is details code.please help me .

Regards

Member Avatar for diafol

You're overwriting the $includes on every iteration...

$includes = array();
foreach($per as $p) {
      $inclues[] =  $p;

    }
$data['whats_include'] = implode(", ", $includes);
dumpVar($data);    

Hi, Thanks for reply.but its nothing pass any single data. :(
**i used it like **

$includes = array();
$per = $_POST['whats_include'];    
foreach($per as $p) {
      $inclues[] =  $p;
    }
$data['whats_include'] = implode(", ", $includes);
dumpVar($data); 

Output :

Array
(
    [user_id] => 1
    [trip_name] => bangla tour
    [tour_type] => none
    [day] => 
    [nights] => 
    [service_level] => ---None---
    [min_person] => 3
    [max_person] => 5
    [whats_include] => 
)

now what will i do? please

Many thanks for help me its working now and you always help me as a Master

please see i used like this:

$myvalue = $_POST['whats_include'];
        foreach ($myvalue as $avalue)
            {
            $include[] = $avalue;
            }
        $p = implode(", ", $include);   
        $data['whats_include'] = $p;

Thanks again. :)

Member Avatar for diafol

I included the loop as I thought you wanted to do something with the individual values, but if not, why not do this?

$data['whats_include'] = implode(", ", $_POST['whats_include']);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.