Jump to content

Array instead of value


timmah1

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.