title: How to add multiple Checkbox value to database
body: <p>I have a database named "student1905" where there is a table named "programmata" where there is a column named "Periorismoi". </p>
  
  <p>I have a page where there are some checkboxes. All i want to do is add the value of the TICKED  (selected) checkboxes into the column "Periorismoi" with a "," between them. I am thinking of a function where variable named "ids" will take all the values. And then ids will be added in the column. But something is wrong and I cannot find it although I am googling like hell. Here is a part of the code from the page with the checkboxes :</p>
  
  <pre><code>    &lt;form action="Insert4.php" method="POST" periorismoi="periorismoi"&gt;
          &lt;p&gt;
  &lt;input type="checkbox" name="periorismoi[]" value="TRALALALA"&gt;Προβλήματα Όρασης&lt;br&gt;
  &lt;input type="checkbox" name="periorismoi[]" value="2"&gt;Προβλήματα Ακοής&lt;br&gt;
  &lt;input type="checkbox" name="periorismoi[]" value="3"&gt;Κινητικά Προβλήματα &lt;br&gt;
  &lt;input type="checkbox" name="periorismoi[]" value="4"&gt;Σοβαρές κινητικές διαταραχές (σε αναπηρικό καροτσάκι)&lt;br&gt;
  &lt;input type="checkbox" name="periorismoi[]" value="5"&gt;Κατάθλιψη&lt;br&gt;
  &lt;input type="checkbox" name="periorismoi[]" value="6"&gt;Άγχος&lt;br&gt;
  &lt;input type="checkbox" name="periorismoi[]" value="7"&gt;Δεν μπορεί να γράφει και να διαβάζει
  &lt;/p&gt;
  &lt;p align="center"&gt;&lt;input type="submit" name="Submit" value="ΠΡΟΣΘΗΚΗ"&gt;&lt;/p&gt;
  &lt;p align="left"&gt; &lt;br&gt;&lt;/p&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>and here is the code from the Insert (to database) page I had at the beginning which is wrong because it is putting at the database the checkbox number:</p>
  
  <pre><code>$link = mysql_connect('localhost', 'student1905','123456');
  mysql_select_db('student1905');
  if(!$link) 
  {
     die('Could not connect: ' . mysql_error());
  }
  else {
      $periorismoi = $_POST['periorismoi'];
      for($i=0; $i&lt;sizeof($periorismoi);$i++){ 
      $sql="INSERT INTO programmata (Auxon,Title,Periorismoi)
      VALUES ('','$title','$periorismoi[$i]')";
      mysql_query($sql);
    }
        header("Location:dokimastiko.php"); ; 
      }
  ?&gt;
  </code></pre>
  
  <p>I tried to do that but it didnt work:</p>
  
  <pre><code>$i = 0;
  $ids = "";
  $first = true;
  while(isset($_POST['periorismos[$i]'])) 
  {
          if($first) {
                  $first = false;
          } else {
                  $ids += ","
          }
          $ids += $_POST['periorismos[$i]'];
          $i++;
  }
  $link = mysql_connect('localhost', 'student1905','123456');
  mysql_select_db('student1905');
  if(!$link) 
  {
     die('Could not connect: ' . mysql_error());
  }
  else {
         mysql_query("SET NAMES utf8");
         $sql = "INSERT INTO programmata (Auxon, Title, Periorismoi) VALUE ('','$title','$ids')";
         mysql_query($sql);
        header("Location:dokimastiko.php"); ; 
      }
  </code></pre>