mysql - How to insert an array into the database without inserting every loop in php -


i have array checkbox

<?php     $query = $handler->query("select * colors");     while ($row = $query->fetch()) {?>  <input type="checkbox" name="check_list[]" id="<?php echo $row['id']?>" value="<?php echo $row['hex'];?>"> <?php } ?> 

php query

<?php     if(!empty($_post['check_list'])) {     foreach($_post['check_list'] $check) {     $query = $handler->query("insert images (color_tags) values ('$check')");         }     }         ?> 

i want insert data's array without inserting on every row want separated in commas data1,data2,data3 insert it.

store in json.

json_encode($array)  <?php if(!empty($_post['check_list'])) {  $query = $handler->query("insert images (color_tags) values ( json_encode($_post['check_list']))");  } ?> 

Comments