timmah1 Posted December 30, 2010 Share Posted December 30, 2010 I have a form that the admin can pick which sizes to offer <input type="checkbox" name="size[]" id="checkbox" value="sm" /> <input type="checkbox" name="size[]" id="checkbox" value="med" /> <input type="checkbox" name="size[]" id="checkbox" value="lg" /> <input type="checkbox" name="size[]" id="checkbox" value="xl" /> Now, when I echo these, I get array instead of the sizes. What am I doing wrong here? I'm sure it's something simple $size[] = $_POST['size']; $size1 = explode(",", $size); Quote Link to comment https://forums.phpfreaks.com/topic/223044-array-instead-of-value/ Share on other sites More sharing options...
dragon_sa Posted December 30, 2010 Share Posted December 30, 2010 $size=$_POST['size']; foreach ($size AS $selected) { echo $selected."<br/>"; } at the moment you are trying to explode the array Quote Link to comment https://forums.phpfreaks.com/topic/223044-array-instead-of-value/#findComment-1153192 Share on other sites More sharing options...
timmah1 Posted December 31, 2010 Author Share Posted December 31, 2010 Thank you, but now how is that going to work putting it into the db? I thought exploding it would list the value for size as sm,med,lg, and so forth Quote Link to comment https://forums.phpfreaks.com/topic/223044-array-instead-of-value/#findComment-1153198 Share on other sites More sharing options...
timmah1 Posted December 31, 2010 Author Share Posted December 31, 2010 How can I keep all the values of the 7 checkboxes of sizes[] as 1 value separated by commas like this sm,med,lg,xl,2x,3x,all I have the checkboxes like this <table border="0" cellpadding="5" cellspacing="0"> <tr> <td>SM</td> <td> </td> <td><input type="checkbox" name="size[]" id="checkbox" value="sm" /></td> </tr> <tr> <td>MED</td> <td> </td> <td><input type="checkbox" name="size[]" id="checkbox" value="med" /></td> </tr> <tr> <td>LG</td> <td> </td> <td><input type="checkbox" name="size[]" id="checkbox" value="lg" /></td> </tr> <tr> <td>XL</td> <td> </td> <td><input type="checkbox" name="size[]" id="checkbox" value="xl" /></td> </tr> <tr> <td>2X</td> <td> </td> <td><input type="checkbox" name="size[]" id="checkbox" value="2x" /></td> </tr> <tr> <td>3X</td> <td> </td> <td><input type="checkbox" name="size[]" id="checkbox" value="3x" /></td> </tr> <tr> <td>One size fits all</td> <td> </td> <td><input type="checkbox" name="size[]" id="checkbox" value="all" /></td> </tr> </table> Then I want to be able to store those the values in the database Quote Link to comment https://forums.phpfreaks.com/topic/223044-array-instead-of-value/#findComment-1153206 Share on other sites More sharing options...
sasa Posted December 31, 2010 Share Posted December 31, 2010 use implode() function Quote Link to comment https://forums.phpfreaks.com/topic/223044-array-instead-of-value/#findComment-1153275 Share on other sites More sharing options...
timmah1 Posted December 31, 2010 Author Share Posted December 31, 2010 Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/223044-array-instead-of-value/#findComment-1153306 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.