Yes it is. You will want to have the prev/next buttons submit to the same page, where hidden values pass the values for the previous and next months and years, and submit button buttons that pass whether you want the previous or the next one.
However, if you instead want a calendar that can be updated without reloading the page, jQuery has a nice datepicker that can be scripted in many different ways.
If you don’t want the page to reload then you won’t be using a PHP solution.
You should still have a PHP solution for those who do not run javascript. Then for those who do run javascript, you can instead use scripting to disable the calendar and replace it with the javascript one.
I suggest that once you get the PHP version working as you require, that you then head on over to the javascript forum and ask them about using ajax to update the datepicker calendar. The basic idea will be to use ajax to request from the server for the previous and next month and year, so that you can then quickly update the links when you show the new calendar page.
It now flips through months perfectly, however i have one minor issue. When i click on a month for example the First of June, it links to a page like this:
Thanks guys, i think i have not explained properly. I dont want to show the actual days as 01, 02, 03 i want to when the link is clicked take users to the required page like so [
So the calendar would look exactly the same as it does now, for example on the calendar if i click on ‘1’ in the Month of June it would have a value in the querystring as 01. So i need to convert the date somehow. I tried using number_format but that didn’t work.
Anyway i added this line:
[QUOTE]
$day_num = 1; //Just after this line
$day_num = str_pad($day_num, 2, “0”, STR_PAD_LEFT);
And it converts ‘1’ to ‘01’. Can i achieve what i have explained above?
This post has been chosen to be answered by the Internet Oracle.
> i want to when the link is clicked take users to the required page
} Hello dear supplicant,
}
} It appears that you are using the $day_num variable in two
} different places even though you require different content.
}
} I suggest that you use two different variables so that you can
} apply different content in different places.
}
} You owe the Oracle a way to relive his glory days
}
} Signed,
} The Internet Oracle
hey i begginer in php and i would like some help.
in this calendar there is a problem…
when someone trying to change year it goes to 1970.
can some one help with that.
<?php
//This gets today's date
$date = (!isset($_GET['month']) && !isset($_GET['year'])) ? time() : strtotime($_GET['month'] . '/1/' . $_GET['year']);
//This puts the day, month, and year in seperate variables
$day = date('d', $date) ;
$month = date('m', $date) ;
$year = date('Y', $date) ;
//Here we generate the first day of the month
$first_day = mktime(0,0,0,$month, 1, $year) ;
//This gets us the month name
$title = date('F', $first_day) ;
//Here we find out what day of the week
$day_of_week = date('D', $first_day) ;
//Once we know what day of the week it falls on, we know how many blank days
//occure before it. If the first day of the week is a Sunday then it would be zero
switch($day_of_week){
case "Sun": $blank = 0; break;
case "Mon": $blank = 1; break;
case "Tue": $blank = 2; break;
case "Wed": $blank = 3; break;
case "Thu": $blank = 4; break;
case "Fri": $blank = 5; break;
case "Sat": $blank = 6; break;
}
//We then determine how many days are in the current month
$days_in_month = cal_days_in_month(0, $month, $year) ;
?>
<div id="php-calendar" class="right">
<table>
<!--<tr><th colspan='7'><? echo $title. " ".$year; ?></th></tr>-->
<?php echo "<tr><th colspan=7><a href=\\"?month=". ($month - 1) . "&year=$year\\"><<</a> $title $year <a href=\\"?month=" . ($month + 1) . "&year=$year\\">>></a></th></tr>"; ?>
<tr><td width=42>S</td><td width=42>M</td><td width=42>T</td><td width=42>W</td><td width=42>T</td><td width=42>F</td><td width=42>S</td></tr>
<?php
$day_count = 1;
echo "<tr>";
while ( $blank > 0 )
{
echo "<td></td>";
$blank = $blank-1;
$day_count++;
}
//sets the first day of the month to 1
$day_num = 1;
//count up the days, untill we've done all of them in the month
while ( $day_num <= $days_in_month )
{
echo "<td> <a href='general-courses/?day=$day_num $title $year'>$day_num</a></td>";
$day_num++;
$day_count++;
//Make sure we start a new row every week
if ($day_count > 7)
{
echo "</tr><tr>";
$day_count = 1;
}
}
//Finaly we finish out the table with some blank details if needed
while ( $day_count >1 && $day_count <=7 )
{
echo "<td> </td>";
$day_count++;
}
?>
</table>
</div> </div>
A simple solution is to perform some bounds checking on the month, so that the right arrows, that go to the next month, use the following for the month