Hey everyone,
I have this script going through an array of dates, and I want to add something in my db if none of the dates posted from my form are in the db.
example:
$start = $_POST['startdate'];
$end = $_POST['enddate'];
$check = $start;
while ($check != $end) {
$query = "SELECT date FROM calendar where date='$check'";
$result = mysql_query($query) or die(mysql_error());
$numrows = mysql_num_rows($result);
if($numrows != 0)
{
echo "don't enter this date: $check. <br />";
}
else
{
echo "enter this date: $check. <br />";
mysql_query("INSERT INTO calendar (`propertyID`,`date`,`client`,`startdate`,`enddate`) VALUES ('$propertyID','$check','$client','$start','$end')") or die(mysql_error());
}
$check = date ("Y-m-d", strtotime ("+1 day", strtotime($check)));
}
This will output a list of dates with "add" or "don't add" depending if the date is present in my db until it reaches my end date. What I want to do is go through the list and if none of the dates in my loop match the ones in my db, then add them to the calendar table, and if 1 date is present in the db, then display an error message and nothing is entered.
What do you recommend?
Thanks!