Getting dates in database table into calendar

I am working with the php calendar at http://php.about.com/od/finishedphp1/ss/php_calendar.htm

I have a table in my database with fields

periodid int auto_increment primary key
startdate date not null
enddate date not null

All dates between the startdate and enddate need to be identified on calendar. Startdate and enddate can be any dates with more than one period in a month.

From my query to database I am creating arrays


while ($getdates = @mysql_fetch_array($datessql))	{
			$startdate[] = $getdates['startdate'];
		
			
			$enddate[] = $getdates['enddate'];
$pricesperiodid[] = $getdates['pricesperiodid'];

then combining arrays like this


if (isset($startdate))	{	
			$pricesperiodstart = array_combine($pricesperiodid, $startdate);
			}
	if (isset($enddate))	{
			$pricesperiodend = array_combine($pricesperiodid, $enddate);
			}
		}

Help! At this point I am stuck! I am wanting to generate all the dates required into another array so that I can then check against the calendar dates using

in_array

Or is there a completely different way anybody can suggest??

I’d make a function. To make a list of dates from start to end.
And fill an array with this.

the only thing I don’t understand is how to use periodid if there are more than one for one date.

My thinking with periodid was that I could use this to avoid confusion between various periods if we had, for example during March a startdate of 2nd and enddate of 6th and another startdate of 8th and enddate of 12th, the arrays would be something like this with the index to both arrays being the periodid.

array( [1] => 2009-03-02 [2] => 2010-03-08 ) for startdate and
array( [1] => 2009-03-06 [2] => 2010-03-12 ) for enddate

However if making an array as you suggest this may be irrelevant.

Lets talk about the goal. The interface.
What’s the use of matched dates? A link with periodid? What if there are 2 periods for one date?

Or there are a link to the certain date, and there are all periods displayed?

I think my original idea with matched dates was irrelevant and confusing the issue, and an array with all dates is a much beter idea.

I have now had time to put the array together as Shrapnel_NS suggested like this


while ($getdates = @mysql_fetch_array($datessql))	{
			$startdate = strtotime($getdates['startdate']);
$enddate = strtotime($getdates['enddate']);
while ($startdate <= $enddate )	{
		
		$arraydates[] = date('Y-m-d',$startdate);	
			$startdate = $startdate + 86400;
		
		}
	
		}
		
		print_r($arraydates);

This leaves me with one discrepancy which I am struggling to rectify. The very last date that should be in the array is missing. How can I correct this without loosing the first date?