0

My array of checkbox inputs is displaying and working perfect:

<input name="seminar[<?php echo $a; ?>]" type="checkbox" id="seminar_<?php echo $a; ?> "value="" <?php echo $checked; ?>>

This is my MySQL insert data ($s):

if ($seminar) { 
    foreach ($seminar as $s )
        $interest .= "$s ";
}

My earlier for loop that processes the checkbox inputs above, does not store the data in $s. And I am trying to find a way to store those values to pass to that foreach.

3
  • I tried ...foreach ($seminar[$a]... but obviously that does not work because my earlier loop is confined to the generation of the checkboxes. Commented Jan 17, 2011 at 21:43
  • 1
    Please reformat code, because right now it looks like your checkboxes have empty value. Of course this explains why you will not get anything in $interest string except for spaces, but I don't think that the problem is so trivial :) Commented Jan 17, 2011 at 21:48
  • I am working with someone elses code, and its seems like it's just a mess of junk! This was done so wrong I am finding out now. Commented Jan 17, 2011 at 22:03

1 Answer 1

1
<input type="checkbox" name="apple[]" value="1">
<input type="checkbox" name="apple[]" value="2">
<input type="checkbox" name="apple[]" value="3">

your checkbox is something like this...............ok.

then in php you just post the variable

<?php $apple=$_POST['apple'];
   ?>

now the $apple is an array of your selected values. is it ok for your project.....................

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the helpful insight.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.