I am currently working on a project and it is basically a scheduling web app. I have one page where users enter some text that will be save for the current day.
Users are also allowed to make entries for the next and previous day, or using a calendar.
At the bottom of my page I have two buttons: previous and next day.
I would like to be able to click, for example, in the next day and display the date of the next day at the top of the page. And once I am in the page of the next day, if I click next day again I should go to the next next day, i.e., two days a head. And so on. The same would be applied to the previous day.
So, I need a way to continuously go forward and backward in the calendar using the buttons.
So far, I can go to the imediately next and previous day, but I cannot continue.
These are the links at the bottom of the page:
<a href="builder.php?day=previous" id="btn_previous_day">Previous day</a>
<a href="builder.php?day=next" id="btn_next_day">Next day</a>
This is how I find which link was clicked. This code is at the top of the page
<?php
$_SESSION['prev'] = 0;
$_SESSION['next'] = 0;
if(isset($_GET['day']))
{
if( $_GET['day'] == 'previous' )
{
$_SESSION['prev']--;
$currentDay = date('j m o', strtotime(' - ' . $_SESSION['prev'] . ' day'));
}
if($_GET['day'] == 'next')
{
$_SESSION['next']++;
$currentDay = date('j m o', strtotime(' + ' . $_SESSION['next'] . ' day'));
}
} else {
$currentDay = date('j m o');
}
?>
And here is where a output the current day:
<p><input type="text" id="title" style="border: none;" name="title" size="20" value=" WOD <?php echo $currentDay; ?>"/></p>
Thank you!!!!