Basically, I have a function that creates a calendar and only needs modifying to display the next/prev month in a calendar ie. createCal($nextM, $y)
and I just need to call this function with the new parameters whenever someone clicks a link. I don't think we can use javascript so i'd like to avoid that if at all possible.
Pretty much, all i want to do is something like--
if (user clicks on 'next') then
createCal($nextM, $y)
else if (user clicks on 'prev') then
createCal($prevM, $y)
^is there anything I can do like this above? Thanks!
There are lots of ways to do this. One suggestion is to use a $_GET
parameter to send the month you want to display. Something like:
PHP:
if (isset($_GET['month'])) {
createCal($_GET['month'], $y)
}
HTML:
<a href='cal.php?month=<?=$nextM?>'>Next Month</a>
<a href='cal.php?month=<?=$prevM?>'>Prev Month</a>
Depending on your system, you might also want to send the year - for situations where next month is Jan of the next year, or previous month is Dec last year...