---
title: "array_diff to insert all unchecked checkbox"  
description: "array_diff to insert all unchecked checkbox"  
author: "Tan WY"  
published: 2014-08-06  
updated: 2014-08-06  
canonical: https://www.mindstick.com/forum/2028/array_diff-to-insert-all-unchecked-checkbox  
category: "php"  
tags: ["php"]  
reading_time: 1 minute  

---

# array_diff to insert all unchecked checkbox

[anyone](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) know is it possible to make [INSERT](https://www.mindstick.com/blog/173/executing-insert-delete-or-update-query-in-sqlserver-using-ado-dot-net) all [checkbox](https://www.mindstick.com/articles/291/how-should-use-checkbox-control-in-vb-dot-net) [values](https://www.mindstick.com/forum/327/sum-textbox-values) into the [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) when there is not even one checkbox being checked since im using array_diff as shown below?\
\
my [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) currently facing is,\
when there is a checkbox being checked, it will insert into checked_table and the remaining [options](https://www.mindstick.com/articles/43878/making-the-best-use-of-the-options-trade-ideas) which did not selected will insert into unchecked_table.\
howewer, when all checkbox didnt being selected, and click on [submit button](https://www.mindstick.com/forum/12834/make-text-appear-when-submit-button-clicked-and-checkbox-is-unchecked), the [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) didnt send to my database unchecked_table.

```
<?php	include('connect.php');	$checked = ($_POST['date']);	$unchecked = ($_POST['nondate']);	$diff = array_diff($unchecked,$checked);if(isset($_POST['date'])){foreach ($_POST['date'] as $dateValue){$insert="INSERT INTO checked_table ($colm_ladate) VALUES ('$dateValue')";		mysql_query($insert);}		echo header("location:home.php");		}if (isset($_POST['nondate']))		{		foreach ($diff as $dateValue2)		{	$insert2="INSERT INTO unchecked_table($colm_lrdate) VALUES ('$dateValue2')";	mysql_query($insert2);		}	echo header("location:home.php");} ?>
```


---

Original Source: https://www.mindstick.com/forum/2028/array_diff-to-insert-all-unchecked-checkbox

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
