Jump to content

Recommended Posts

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);

Link to comment
https://forums.phpfreaks.com/topic/223044-array-instead-of-value/
Share on other sites

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

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.