Question about Checkbox. How to mark several checkboxes and put their values ​​in the database, all selected in one cell? After all, only the first value is added.

<label> <input type="checkbox" name="den" value="Понедельник" id="CheckboxGroup1_0" /> Понедельник</label> <br /> <label> <input type="checkbox" name="den" value="Вторник" id="CheckboxGroup1_1" /> Вторник</label> <br /> <label> <input type="checkbox" name="den" value="Суббота" id="CheckboxGroup1_2" /> Суббота</label> 

.

  $result = mysql_query("INSERT INTO students (den) VALUES ('$den')"); if ($result == 'true') {echo "Добавлен!";} else {echo "НЕТ!";} 

    2 answers 2

    The server receives an array den [], to write all the values ​​into one cell, they must be concatenated before insertion, for example, like this:

     $joined_den = join(",", $den); 

      Call the buttons not den, but den [], then in the arrived $ den you will receive an array of values, one by one and add them (foreach).