Jump to content

Replica of the Previous and Next day button of MS Outlook


kamal213

Recommended Posts

Hi guyz,

 

I have created an event calender with PHP for customer appointments (calender.php).

 

It is very basic and simple were all the days in the month are clickable; click on the day and you are redirected to diary page (diary.php) to view the appointments for that day.

 

At the moment after the user is done looking at appointment and want to view another, they have to go back to the calender.php page for the next/previous day. I would like a previous and next button (Like the calender on MS Outlook) on the (diary.php page) so I don't have to keep going back to the calender.php page to go to the next or previous day.

 

Please guys help me out, I realise it is quite complicated so any suggestions, ideas, or even if you have a similar script to see how you did it would be much appreciated and very helpful.

 

Thanks guys!

Link to comment
Share on other sites

It's not actually sending any data to the dairy page. Sorry I didn't explain properly but appointments are not actually booked on the calender; that's done seperately the calender only has the days of the month and the days are links - the diary page only displays the appointments.

 

Soz I wasn't clear hope this helps.

Link to comment
Share on other sites

It's not actually sending any data to the dairy page. Sorry I didn't explain properly but appointments are not actually booked on the calender; that's done seperately the calender only has the days of the month and the days are links - the diary page only displays the appointments.

 

Soz I wasn't clear hope this helps.

 

OK, so the diary page is accessed via a link. So, when the user clicks a date in the calendar to open the diary I would assume that there are some parameters included in the URL of that link to specify what day is supposed to be displayed in the diary (so you WOULD be sending data to the diary page). Otherwise, how does the diary page know what day to display?

 

I would guess the links in the calendar might look something like:

<a href="diary.php?date=20110601">June 6</a>

 

We would need to see what the format of the parameters are that you are passing on the query string. From that it would be very easy to create Next/Prev links in the diary page.

Link to comment
Share on other sites

Exactly the page is accessed via a link.

 

This is how:

echo "><a href='diary.php?&day=" . $day . "&month=" . $month . "&year=" . $year . "&v=true'>".$i."</a></td>";

 

were $i repesents the days of the month in the calender (which is incrementing)

 

Apologies for the misunderstanding

Link to comment
Share on other sites

function diaryHrefFromTimestamp($timestamp)
{
    $day   = date('d', $timestamp);
    $month = date('m', $timestamp);
    $year  = date('Y', $timestamp);
    return "diary.php?&day={$day}&month={$month}&year={$year}&v=true";
}

//Get vars from URL
$day   = $_GET['day'];
$month = $_GET['month'];
$year  = $_GET['year'];

//Create timestamps for prev/next days
$prevDayTimestamp = strtotime("$day-$month-$year -1 day");
$nextDayTimestamp = strtotime("$day-$month-$year +1 day");

//Create href values for prev/next links
$prevDayHref = diaryHrefFromTimestamp($prevDayTimestamp);
$nextDayHref = diaryHrefFromTimestamp($nextDayTimestamp);

echo "<a href='{$prevDayHref}'>Previous</a>\n";
echo "<a href='{$nextDayHref}'>Next</a>\n";

 

If the date passed in the URL was today's date the output from the above would be

<a href='diary.php?&day=31&month=05&year=2011&v=true'>Previous</a>
<a href='diary.php?&day=02&month=06&year=2011&v=true'>Next</a>

Link to comment
Share on other sites

Lol! Wow

 

What can I say; your not just a GURU of PHP ur the Alexandra the great..the Genghis khan of PHP. Your should be inaugurated into the PHP Hall of fame if there was one.

 

Basically it worked! I don't get how I spent hour trying to figure out how in you solved it and you did it with one post..I guess I have a long was to go in PHP!

 

Thanks again

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.