Jump to content

Looping through dates and seeing if there's a match in the DB


86Stang

Recommended Posts

I've built a basic for loop to loop through the next two weeks worth of days:

 

$qry = "SELECT live_date FROM table";
$result = mysql_query($qry) or die("Error during query!");

$days_outlook = 14;
$cur_date = date('Y-m-d');

for ($i=strtotime($cur_date);$i<strtotime(date("Y-m-d", strtotime($cur_date)) . " +$days_outlook days");$i+=86400)
{
	echo date('Y-m-d', $i) . "<br>";
}

 

Works great.  What I'd like to do now is compare each date in the loop with the 'live_date' column of a database and if the looping date matches a date within the 'live_date' column don't display it (or maybe display it differently than the dates with no match).  Any chance I can get a hand on this?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.