I am trying to store the contents of checkboxes in a field in a mysql database and retireve them later...
<input type="checkbox" name="days[]" class="other" value="Monday" />
<label class="left">Monday</label> <br />
<input type="checkbox" name="days[]" class="other" value="Tuesday" />
<label class="left">Tuesday</label> <br />
<input type="checkbox" name="days[]" class="other" value="Wednesday" />
<label class="left">Wednesday</label> <br />
<input type="checkbox" name="days[]" class="other" value="Thursday" />
<label class="left">Thursday</label> <br />
<input type="checkbox" name="days[]" class="other" value="Friday" />
<label class="left">Friday</label> <br />
<input type="checkbox" name="days[]" class="other" value="Saturday" />
<label class="left">Saturday</label> <br />
<input type="checkbox" name="days[]" class="other" value="Sunday" />
<label class="left">Sunday</label> <br />
$days = implode(",",$_POST['days']);
.
.
mysql_query("INSERT INTO users (..., days, ...) VALUES (.., '$days', ..)") or die("something went wrong during the registration. MySQL said: ".mysql_error());
(the "..." means that there is other information, yes those are confirmed working, inserted as well)
This is what I use to retrieve the data:
$result = mysql_query("SELECT * FROM users where verified = 0");
while($info = mysql_fetch_array($result, MYSQL_ASSOC)) {
.
.
.
$days = explode(",", $info['days']);
foreach ($days as $value){
echo $value;
echo "<br/>";
}
.
.
.
}
(obviously, the .'s mean other - confirmed working - code)
Problem is that the $value comes out as "array"...what the heck am I doing wrong?
Thanks!