Forum Moderators: coopster
This is the code which links the numbered day to another page:
echo ' <a href="depday.php?year='.$Year.'&month='.$Month.'&day='.$calendar_day.'"> '.$calendar_day,'</a> ';
Here is my current SQL query..
$sqlquery = "SELECT id, diwtitle, date_string FROM diw_alpha WHERE '$calendar_day' = date_string ORDER BY date_string";
Looks like you need to concatenate your variables. Is your date field in the YYYY-MM-DD format? If so try this:
$day = $_GET['day'];
$year = $_GET['year'];
$month = $_GET['month'];
$cal_string = $year . "-" . $month . "-" . $day;
$sqlquery = "SELECT id, diwtitle, date_string FROM diw_alpha WHERE date_string = '$cal_string' ORDER BY date_string";
dc
I appended my code as you recommended, and when I click on a date in the calendar, it passes along all events which have a YYYY-MM-DD of 0000-00-00. (No date was entered when the event was put into the db)
So I am thinking that the date from the calendar page is not being successfully passed to the depday.php page.
I changed the variables to begin with a capital letter since that's what I use in this calendar. I am pretty lost now as to what may be causing it. My hopes is that it is something simple.I have never written a calendar before, so this is uncharted territory for me. Here's the code for the calendar..
$Month=$_GET['Month'];
$Year=$_GET['Year'];
$now=time();
if ($Month=="")
$Month=date("F",$now);
if ($Year=="")
$Year=date("Y",$now);
switch($Month)
{
case "January" :
$days="31";
break;
case "February" :
if ($Year%4=="0") $days="29";
else $days="28";
break;
case "March" :
$days="31";
break;
case "April" :
$days="30";
break;
case "May" :
$days="31";
break;
case "June" :
$days="30";
break;
case "July" :
$days="31";
break;
case "August" :
$days="31";
break;
case "September" :
$days="30";
break;
case "October" :
$days="31";
break;
case "November" :
$days="30";
break;
case "December" :
$days="31";
break;
}
$day="Sunday";
$daynum=strtotime("$Month 1 $Year");
$day=date("l",$daynum);
switch($day)
{
case "Monday" :
$startpos="2";
break;
case "Tuesday" :
$startpos="3";
break;
case "Wednesday" :
$startpos="4";
break;
case "Thursday" :
$startpos="5";
break;
case "Friday" :
$startpos="6";
break;
case "Saturday" :
$startpos="7";
break;
case "Sunday" :
$startpos="1";
break;
}
columns we need
$basenum=$startpos+$days-1;
$rows=ceil($basenum/7);
$rowcount="1";
$daycount="1";
$calendar_day=0;
while ($rowcount<=$rows)
{
echo "<tr>";
$day_column=1;
while ($day_column<=7)
{
echo "<td>";
if ($daycount<$startpos)
echo " ";
elseif (($daycount-$startpos+1)>$days)
echo " ";
else
{
$calendar_day=$calendar_day+1;
echo ' <a href="depday.php?year='.$Year.'&month='.$Month.'&day='.$calendar_day.'"> '.$calendar_day,'</a> ';
// echo "$calendar_day";
}
$daycount=$daycount+1;
echo "</td>";
$day_column=$day_column+1;
}
echo "</tr>";
$rowcount=$rowcount+1;
}
echo "</table>";