Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have 3 checkboxes :

<input class="shoesChoice" name="trendy" type="checkbox" />
<input class="shoesChoice" name="luxury" type="checkbox" />
<input class="shoesChoice" name="sports" type="checkbox" />

And I want to store this information into (if possible) only one field in my database. So, if the 1rst and the last input are checked, my shoesChoice field should have : "trendy, sports"

share|improve this question
    
just concatenate the value server side. explode : php.net/manual/en/function.explode.php implode : php.net/manual/en/function.implode.php – Hugo Dozois Feb 19 '13 at 14:36
    
Useful, thanx ! – Kaherdin Feb 19 '13 at 15:05
up vote 1 down vote accepted

Try to change the name and keep them in value

<input class="shoesChoice" name="shoes[]" value="trendy" type="checkbox" />
<input class="shoesChoice" name="shoes[]" value="luxury" type="checkbox" />
<input class="shoesChoice" name="shoes[]" value="sports" type="checkbox" />

In PHP, try to get values in this way:

<?php
 if(isset($_REQUEST['shoes']))
 {
   $shoes = '';
   foreach
 }

?>
share|improve this answer
    
Thanks, it works like this : $shoes = implode(" ", $_POST['shoes']); – Kaherdin Feb 19 '13 at 15:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.