I have one principal page with two links, and one switch to get those links, and create includes for both:
Links
<div id="g-menu">
<ul>
<li> <a href="?link=1" name="link1">Home</a></li>
<li> <a href="?link=2" name="link1">Calendar</a></li>
</ul>
</div>
Swith
switch ((isset($_GET['link']) ? $_GET['link'] : '')) {
case "1":
include('modules/groups/principal_page.php');
break;
case "2":
$current_month = date('m') - 1; //check the current month
$_GET['id']= $current_month;
$_GET['year']=date('Y'); //check the current year
include 'modules/groups/calendar.php';
break;
default:
include('modules/groups/principal_page.php');
}
The first page is the principal page, the second one, is a page with an calendar.
To do the calendar buttons(back and forward), i used parameters, example, if i want to check the April in 2004 i do that:
calendar.php?id=4&year=2004 //4 because january starts at 0
The problem is that i'm using parameters to do that, and i dont know how to connect the buttons from the links, to the file that the calendar page is being included.
Code from the buttons
<?php }
$id = preg_replace('#[^0-9]#i', '', $_GET['id']);
$get_year = preg_replace('#[^0-9]#i', '', $_GET['year']);
$back= $id - 1;
$back2 = $get_year;
$next= $id + 1;
if($back == 0 || $back == -1){
$back = 12;
$back2 = $get_year - 1;
}
if($id ==12){
++$get_year;
$next= 1;
}
?>
<a href="calendar.php?id=<?= $back?>&year=<?= $back2; ?>"><button class="offersbtn">Back</button></a>
<a href="calendar.php?id=<?= $next?>&year=<?= $get_year; ?>"><button class="offersbtn">Next</button></a>
</div>
<br>
<?php
echo get_date($id,$get_year);
?>
How can I use the navigation buttons without changing the current page that the calendar is being included?