How do get the day selected as a <a href> variable
I am using the code below to show a calendar. The days are clickable using a href. The only problem is i don't know how to get the day variable in the link. I can get the month and year. NOt sure what do pick as the day.
current:
<a href=/page.php?month=$month&year=$year>$i</a>
I need:
<a href=/page.php?month=$month&day=$day&year=$year>$i</a>
code:
<?php
$day = $_GET["day"];
$month = $_GET["month"];
$year = $_GET["year"];
$sel = $_GET["sel"];
$what = $_GET["what"];
$urlprt = $_SERVER['PHP_SELF'];
$qstr = $_SERVER['QUERY_STRING'];
$qss = explode('&',$qstr);
$urllink = $urlprt."?".$qss[0];
if($day == "")
$day = date("j");
if($month == "")
$month = date("F");
if($year == "")
$year = date("Y");
$currentTimeStamp = strtotime("$year-$month-$day");
$monthName = date("F",$currentTimeStamp);
$numDays = date("t", $currentTimeStamp);
$counter = 0;
$numEventsThisMonth = 0;
$hasEvent = false;
$todaysEvents = "";
?>
<table align="center" style="border: 0px solid; width:420px; height:300px;">
<tr>
<td width='50' colspan='1'>
<input type='button' value='< ' onClick='goLastMonth(<?php echo $month . ",
" . $year; ?>)' style="border:0px; width:40px;">
</td>
<td width='250' colspan='5' align='center'>
<span><?php echo "Month : ".$month . " &
Year : " . $year; ?></span><br>
</td>
<td width='50' colspan='1' align='right'>
<input type='button' value=' > '
onClick='goNextMonth(<?php echo $month . ",
" . $year; ?>)' style="border:0px; width:40px;">
</td>
</tr>
<tr>
<td class='head' width='30' style='background-color:#FFFFFF;'>S</td>
<td class='head' width='30' style='background-color:#FFFFFF;'>M</td>
<td class='head' width='30' style='background-color:#FFFFFF;'>T</td>
<td class='head' width='30' style='background-color:#FFFFFF;'>W</td>
<td class='head' width='30' style='background-color:#FFFFFF;'>T</td>
<td class='head' width='30' style='background-color:#FFFFFF;'>F</td>
<td class='head' width='30' style='background-color:#FFFFFF;'>S</td>
</tr>
<?php
$numDays = date("t", $currentTimeStamp);
for($i = 1; $i < $numDays+1; $i++, $counter++)
{
$timeStamp = strtotime("$year-$month-$i");
if($i == 1)
{
// Workout when the first day of the month is
$firstDay = date("w", $timeStamp);
for($j = 0; $j < $firstDay; $j++, $counter++)
{
if($j==0)
{
echo "<td style='background-color:#FFFFFF;'> </td>";
}
else
{
echo "<td style='background-color:#FFFFFF;'> </td>";
}
}
}
if($counter % 7 == 0)
{
$counter=0;
echo "</tr><tr>";
if($i == date("d") && $month == date("F") && $year == date("Y"))
{
echo "<td width='30' style='background-color:#FFFFFF;'>
<b><a id=caldates href=/schedule.php?>$i</a></b></td>";
}
else
{
echo "<td width='30' style='background-color:#FFFFFF;'>
<a id=caldates href=/schedule.php?>$i</a> </td>";
}
}
else
{
if($i == date("d") && $month == date("F") && $year == date("Y"))
{
echo "<td width='30' style='background-color:#FFFFFF;'><b><a id=caldates href=/schedule.php?>$i</a></b></td>";
}
else
{
echo "<td width='30' style='background-color:#FFFFFF;'>$i</td>";
}
}
}
?>
<?php
$monthName = date("F", $currentTimeStamp);
?>
</table>
<script>
<?php
$month = date("F");
?>
function goLastMonth(month, year)
{
// If the month is January, decrement the year
if(month == 1)
{
--year;
month = 13;
}
document.location.href = '<?php echo $urllink; ?>&month='+(month-1)+'&year='+year;
}
function goNextMonth(month, year)
{
// If the month is December, increment the year
if(month == 12)
{
++year;
month = 0;
}
document.location.href = '<?php echo $urllink; ?>开发者_JAVA百科&month='+(month+1)+'&year='+year;
}
</script>
Did I misunderstood the question or is it obvious the day is $i
?
精彩评论