How to give unique hyperlink to different day of the month?

i found this script (calendar) on the internet, and i dont know how to give unique hyperlink (a href) to a different day of the month.

Example: if i am clicking on the 14th day, i want that link redirect me to the google.com Example: if 20th day = yahoo.com

...

<?php
$monthNames = Array("January", "February", "March", "April", "May", "June", "July", 
"August", "September", "October", "November", "December");

if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");

$cMonth = $_REQUEST["month"];
$cYear = $_REQUEST["year"];

$prev_year = $cYear;
$next_year = $cYear;
$prev_month = $cMonth-1;
$next_month = $cMonth+1;

if ($prev_month == 0 ) {
$prev_month = 12;
$prev_year = $cYear - 1;
}

if ($next_month == 13 ) {
$next_month = 1;
$next_year = $cYear + 1;
}
?>

<a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>">Previous</a>
<a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>">Next</a><br/>

<?php echo $monthNames[$cMonth-1].' '.$cYear; ?><br/>

<?php 
$timestamp = mktime(0,0,0,$cMonth,1,$cYear);
$maxday = date("t",$timestamp);
$thismonth = getdate ($timestamp);
$startday = $thismonth['wday'];
for ($i=0; $i<($maxday+$startday); $i++) {
if(($i % 7) == 0 ) echo "<tr>";
if($i < $startday) echo "<td></td>";
else echo "<a href='#' style='float:left; margin:0px 5px;'>". ($i - $startday + 1) . "</a>";
if(($i % 7) == 6 ) echo "</tr>";
}
?>

Thank to all of you, for any answers!

Answers


Use elseif($day === number) like so:

<?php

$monthNames = Array("January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December");

if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");

$cMonth = $_REQUEST["month"];
$cYear = $_REQUEST["year"];

$prev_year = $cYear;
$next_year = $cYear;
$prev_month = $cMonth-1;
$next_month = $cMonth+1;

if ($prev_month == 0 ) {
$prev_month = 12;
$prev_year = $cYear - 1;
}

if ($next_month == 13 ) {
$next_month = 1;
$next_year = $cYear + 1;
}
?>

<a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>">Previous</a>
<a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>">Next</a><br/>

<?php echo $monthNames[$cMonth-1].' '.$cYear; ?><br/>

<?php
$timestamp = mktime(0,0,0,$cMonth,1,$cYear);
$maxday = date("t",$timestamp);
$thismonth = getdate ($timestamp);
$startday = $thismonth['wday'];
for ($i=0; $i<($maxday+$startday); $i++) {
    if(($i % 7) == 0 ) echo "<tr>";

    $day = $i - $startday + 1;

    if($i < $startday) {
        echo "<td></td>";
    } elseif( $day === 14) {
        echo "<a href='http://google.com/' style='float:left; margin:0px 5px;'>". $day . "</a>";
    }
    elseif( $day === 20) {
        echo "<a href='http://yahoo.com/' style='float:left; margin:0px 5px;'>". $day . "</a>";
    }
    else {
        echo "<a href='#' style='float:left; margin:0px 5px;'>". $day . "</a>";
    }
    if(($i % 7) == 6 ) echo "</tr>";
}
?>

Need Your Help

how to call an external object using javascript (and AJAX?)

php javascript html ajax ashx

First off, thanks to this community. I'm slowly starting to understand this stuff and I appreciate all the feedback. That said, I come with another question.

Type casting for user defined objects

php casting

Just like we do with __ToString, is there a way to define a method for casting?