I have problem in storing checkbox values in mysql db . How can I fix this code to store all checked values?
There are seven different columns in type must be stored in the database when you checked for rows
This part of the code is responsible for fetching data from the database and put it in a table:
while ($row = mysqli_fetch_array($query)) {
print
"<tr> <td><input type='checkbox' name='check[]' value='
".$row['course_id'].",
".$row['course_name'].",
".$row['day'].",
".$row['place'].",
".$row['hour'].",
".$row['type'].",
".$row['instructor_name']."' /></td>
<td>{$row['course_id']}</td>
<td>{$row['course_name']}</td>
<td>{$row['day']}</td>
<td>{$row['place']}</td>
<td>{$row['hour']}</td>
<td>{$row['type']}</td>
<td>{$row['instructor_name']}</td>
</tr>";
}
print "</table>
<input type='submit' name='Submit' value='Submit'>
</form>";
This part of the code responsible for storing the data in databases
if(isset($_POST['check'])){
$returned = $_POST['check'];
$office = array('course_id','course_name','day','place','hour','type','instructor_name');
$values = array();
foreach($office as $selection){
$insert1 ="INSERT INTO initial_registration
(course_id,course_name,day,place,hour,type,instructor_name)
SELECT *
FROM offerd_course";
mysqli_query($insert1) or die(mysqli_error());
}
}