kamal213 Posted June 1, 2011 Share Posted June 1, 2011 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! Quote Link to comment Share on other sites More sharing options...
xyph Posted June 1, 2011 Share Posted June 1, 2011 How are you sending data to your diary.php page? Sessions? POST? GET? Quote Link to comment Share on other sites More sharing options...
kamal213 Posted June 1, 2011 Author Share Posted June 1, 2011 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. Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 1, 2011 Share Posted June 1, 2011 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. Quote Link to comment Share on other sites More sharing options...
kamal213 Posted June 1, 2011 Author Share Posted June 1, 2011 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 Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 1, 2011 Share Posted June 1, 2011 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> Quote Link to comment Share on other sites More sharing options...
kamal213 Posted June 2, 2011 Author Share Posted June 2, 2011 Thanks alot mjdamato, I'll check it out and get back to you asap. Quote Link to comment Share on other sites More sharing options...
kamal213 Posted June 2, 2011 Author Share Posted June 2, 2011 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.