Forum Moderators: coopster
In the code below I display 1 to 30 /31 depending on the month.
Now what I want to do is that I want to hyperlink the numbers to a common page say "test.php". That Page will display the whole date.
Can someone help me with the code or point me to an example very very similar to it.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$m=date("m");
$Y=date("Y");
$day = array("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31");
$d=cal_days_in_month(CAL_GREGORIAN,$m,$Y);
Print "<table align=center border=0 cellspacing=0 cellpadding=0 style='width:70%'>";
for ($i=0; $i<$d; $i++){
//echo "$day[$i]";
echo "<td width=15 style='font-weight:bold;color:#CC0066;cellspacing:0;cellpadding:0'>". "$day[$i]"."</td>";
}
?>
</body>
</html>
<?php
$m=date("m");
$Y=date("Y");
// The array wasn't really needed...
$d=cal_days_in_month(CAL_GREGORIAN,$m,$Y);
Print "<table align=center border=0 cellspacing=0 cellpadding=0 style='width:70%'>";
for ($i=1; $i<=$d; $i++){ // Changed to go from 1 to <= $d, instead of 0 to < $d
echo "<td width=15 style='font-weight:bold;color:#CC0066;cellspacing:0;cellpadding:0'><a href='test.php?d=$i&m=$m&y=$y'>$i</a></td>";
}
?>
In test.php put:
<?php
// First line does a bit to keep out mischievous users
if(is_numeric($_GET['y']) && is_numeric($_GET['m']) && is_numeric($_GET['d']))
{
echo $_GET['y'].'-'.$_GET['m'].'-'.$_GET['d'];
}
?>
If you don't want to pass the date and the month view the url too, you'll need to change it slightly.