i m trying to store checkbox values inside variable $days
but when i store this value to database it just store the last selected checkbox inside the database... please help me to sort out the code so i can get all selected values
<?php
if (isset($_POST['days'])) {
foreach ($_POST['days'] as $day) {
$days = " " . $day;
}
} else {
$days = "not available";
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<tr>
<td>Select Days :</td>
<td>
<input type="checkbox" name="days[]" value="Sunday">Sunday
<input type="checkbox" name="days[]" value="Monday">Monday
<input type="checkbox" name="days[]" value="Tuesday">Tuesday
<input type="checkbox" name="days[]" value="Wednesday">Wednesday
<input type="checkbox" name="days[]" value="Thursday">Thursday
<input type="checkbox" name="days[]" value="Friday">Friday
<input type="checkbox" name="days[]" value="Saturday">Saturday
<input type="checkbox" name="days[]" value="All Days">All Days
</td>
<td></td>
Aucun commentaire:
Enregistrer un commentaire