Calendar error - can anyone help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear all

I am trying to create a basic calendar of events and all is working except for the following error:

I have a mySQL database with the following fields:

id - startdate - endate - title - event

I am using the followuing command to select the dates that are booked and colour code the relevant cells of the calendar:

/snip
$sql_currentday = "$year-$month-$zz";
$eventQuery = "SELECT title FROM prestigecal WHERE '$sql_currentday' BETWEEN startdate AND enddate;";
$eventExec = mysql_query($eventQuery);
while($row = mysql_fetch_array($eventExec)) {
if (strlen($row["title"]) > 0) {
echo "<td bgcolor=\"red\" valign=\"middle\" align=\"center\"><font size=\"1px\" face=\"Verdana\">$zz</font></td>\n";
$result_found = 1;

This seems to work and populates the calendar with the correct colours but only if the dates have the fist figure the same 
e.g.

start date = 2002-12-16       end date = 2002-12-19   will populate the cells correctly (i.e. 16 / 17 / 18 / 19)

But if the dates are as follows:

start date = 2002-12-16     end date = 2002-12-20 it populates the correct dates again (i.e.  16 / 17 / 18 / 19 / 20) but also colour codes the date 2002-12-20 for some reason

It seems to think that the 2 (of the 20) is a separate date.

This also applies when you go into other ranges e.g. 2002-12-25 to 2002-12-30 will populate correctly but also the 3rd

can anyone see what is going on with the script and where I have gone wrong.

If any further code of mine is required - just ask.

I would like to get this finish and then post it to the forum in case anyone else would like it

Thanks for your time

Ray

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux