I have a problem inserting the values from checkboxes in an html document into a database as a comma separated string (I know this is usually considered being bad style but in this case that is what is required).
I have an code snippet of the html file here
<div id="page16" class="page">
<p style="font-weight: bold; width: 55%;"><a id="q16_qtext">*</a></p>
<p style="font-style: italic;">Vælg venligst de (højst) 3 primære årsager (i alt).</p>
<p style="font-style: italic;">Af økonomiske årsager:</p>
<input type="checkbox" name="q16[]" value="1" id="num161">For dyrt i forhold til udbyttet for eleverne<br>
<input type="checkbox" name="q16[]" value="2" id="num162">For dyrt i forhold til andre omkostninger (bøger, efteruddannelse af lærere osv.)<br>
<input type="checkbox" name="q16[]" value="4" id="num164">Andre økonomiske årsager<br>
<p style="font-style: italic;">Andre årsager:</p>
<input type="checkbox" name="q16[]" value="5" id="num165">Pga. skolesammenlægning eller en anden større ændring<br>
<input type="checkbox" name="q16[]" value="6" id="num166">Skolen havde/har ikke bemanding til det<br>
<input type="checkbox" name="q16[]" value="7" id="num167">Der var for tidskrævende i forhold til udbyttet (for eleverne i forhold til pensum)<br>
<input type="checkbox" name="q16[]" value="8" id="num168">Der var ikke længere opbakning til det i skoleledelsen (ikke økonomisk)<br>
<input type="checkbox" name="q16[]" value="9" id="num169">Der var ikke længere opbakning til det blandt lærerne<br>
<input type="checkbox" name="q16[]" value="10" id="num1610">Der var ikke længere opbakning til det blandt elever/forældre<br>
<input type="checkbox" name="q16[]" value="11" id="num1611">Andet. Angiv i så fald primært hvad: <a style="text-align: center;"></a><input type="text" name="q16extra" value="" id="num89"><br>
<input type="checkbox" name="q16[]" value="12" id="num1612">Ved ikke<br>
<p style="bottom:5px;"><input style="width: 150px; height: 30px;" type="button" class="all" id="B19" value="tilbage" onClick="showPreviousLayer()"><input style="width: 150px; height: 30px;" type="button" class="all" id="C20" value="fortsæt" onClick="checkAnswersSixteen()"></p>
</div>
Then I connect to a database and use this piece of php code to create an array of the values
$q16 = implode(",",$_POST['q16[]']);
And then insert into "table" with the columns and values. There are of course many other columns and values to be inserted and these work! so the problem seems not to be with the insert statement but with the implode method perhaps.
i tried doing an echo($q16); but that seems just to be empty.
Anyone who knows what the problem might be? please let me know if you need any other information :)