This is a snippet you can use in PHP to retrieve the information needed.
// setup database connection
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
// define the list of values to check for
$values_list = "D1,D2,D3";
// explode list into array
$values = explode(',', $values_list);
// initiate empty array for database values
$db_values = array();
// create the query
$query = "SELECT data FROM table WHERE `data` IN ('" . implode("','", $values) . "')";
// run the query
if ($result = mysqli::query($query)) {
// loop through results and add values to database value array
while($obj = $result->fetch_object()){
$db_values[] = $obj->data;
}
}
$result->close();
// go through given values and check if they are in database value array or not, print result
foreach ($values AS $value) {
if (in_array($value, $db_values)) {
echo "Value $value exists in database.\r\n";
}
else {
echo "Value $value does not exist in database.\r\n";
}
}