title: How can I insert an array into one row?
body: <p>The following code works for inserting an array from a form, but it inserts each value into it's own row. How can I insert an array into one row?</p>
  
  <pre><code>&lt;?php 
  require_once('config.php'); 
  require_once('open_db.php');
  $palette=$_POST['colors_palette'];
  while (list ($key,$val) = @each ($palette)) {
  }
  For ($i=0; $i&lt;sizeof($palette);$i++) {
  $query="INSERT INTO style_test1 (colors_palette) VALUES ('".$palette[$i]."')";
  Mysql_query($query) or die(mysql_error());
  }
  Echo "Record is inserted";
  ?&gt;
  
  &lt;form method="post" action="insert_array.php" &gt;
  &lt;input type="checkbox" name="colors_palette[]" value="jewel" /&gt;                
  &lt;input type="checkbox" name="colors_palette[]" value="bright" /&gt;                     
  &lt;input type="checkbox" name="colors_palette[]" value="soft" /&gt; 
  &lt;input type="checkbox" name="colors_palette[]" value="earth" /&gt;
  &lt;input type="submit" name="Submit" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>