I have a calendar which I would like to check the dates already entered in the db, against the date displayed on the calendar. For the dates that are already entered into the db, I would like to show the cell in a different color, or mark it in some way for ppl to know that there is already something scheduled.
This is the code I have to grab those dates from the db. The array $display_dates contains all the dates. I would like to know how to search through this array to find matches
$select_dates = mysql_query("SELECT * FROM Dates");
$display_dates = mysql_fetch_array($select_dates);
$strip = strtotime("$display_dates[thisdate]");
$dbday = strftime('%d', $strip);
$dbmonth = strftime('%m', $strip);
$dbyear = strftime('%Y', $strip);
Here is the statement I used to get, at the least, the first date in the array to return an "x" in the cell that already has a date entered in the db.
if($day == $dbday & $month == $dbmonth & $year == $dbyear)
echo 'x';
I had a while loop setup:
while($display_dates){
$strip = strtotime("$display_dates[thisdate]");
$dbday = strftime('%d', $strip);
$dbmonth = strftime('%m', $strip);
$dbyear = strftime('%Y', $strip);
But all that did was totally screw up the calendar table format...
I just don't know what I can do to loop through the values in the db and actually allow the dates on the calendar to be marked for every date that appears in the db.
Is this even possible?
Do I need to approach this differently?
Any help is appreciated...Thank you.
🙂