I have a variable which contains multiple dates as string. It's a range of dates. When I send this into the database table, I want to check if the column contains one of these dates. This is hard to do because a variable is a string of multiple dates. Every date excists out of 10 characters. So I send a variable as string into a database which contains multiple or a single date and I want to check if there already is one of those dates which excist out of 10 characters, so if 10 characters without a space between are the same.
Example of a column: https://i.stack.imgur.com/iUiIK.png
$query_overeenkomst = "SELECT * from $stad WHERE beschikbare_data LIKE '%$date%'" or die(mysql_error());
$result_overeenkomst = mysqli_query($conn, $query_overeenkomst);
$rows_overeenkomst = mysqli_num_rows($result_overeenkomst);
if($rows_overeenkomst>=1){
echo "There is a match!";
}
else
{
echo "No date the same.";
}
If I use this code, the column has to contain the whole string of $data (which contains all the dates), but I want to check if there is only one or more dates that match.
The data variable:
$data .= $date->format("Y-m-d") . PHP_EOL;
Returns for example:
2018-12-19 2018-12-20 2018-12-21 2018-12-22 2018-12-23 2018-12-24 2018-12-25