deansatch Posted July 4, 2012 Share Posted July 4, 2012 I have this code which I use to list some events. But I have to make the list into a calendar instead now and still have the event dates clickable. I have been on for bloody ages trying to do this but can't figure out the best way to do it. The date is in the DB as a time() unix timestamp btw $query2 = mysql_query("SELECT * FROM dates WHERE id ='$id' "); while($row2 = mysql_fetch_assoc($query2)){ $date = $row2['date']; echo '<p><a href="book.php?d='.$date.'&f='.$id.'">Book Now</a> for '.date("jS F Y",$date).'</p>'; } Can anyone give me some pointers or suggest the best way to do this? Quote Link to comment https://forums.phpfreaks.com/topic/265216-turn-list-of-events-into-a-calendar-layout/ Share on other sites More sharing options...
Barand Posted July 5, 2012 Share Posted July 5, 2012 Can anyone give me some pointers or suggest the best way to do this? Do what, exactly? Quote Link to comment https://forums.phpfreaks.com/topic/265216-turn-list-of-events-into-a-calendar-layout/#findComment-1359203 Share on other sites More sharing options...
deansatch Posted July 5, 2012 Author Share Posted July 5, 2012 Build a calendar with clickable events, instead of a simple list of events?!? Quote Link to comment https://forums.phpfreaks.com/topic/265216-turn-list-of-events-into-a-calendar-layout/#findComment-1359208 Share on other sites More sharing options...
PFMaBiSmAd Posted July 5, 2012 Share Posted July 5, 2012 Here's one way of doing this - 1) Write or find a calendar script that accepts the year and month number as input values for the calendar month to display. 2) Retrieve the events from your database table that match the year and month number you are trying to display. 3) Loop over the events you just retrieved from your database table and store them in an array of arrays, where the main array index is the YYYY-MM-DD date the event occurs on. The array under each date allows for multiple events on any particular day. 4) In your calendar script, when you are looping over the days in the month, form the YYYY-MM-DD value for the current day and use that to test if there are any events on that date in the array you made in step #3. If there are, loop over and output the events as links in the calendar. 5) Done. Quote Link to comment https://forums.phpfreaks.com/topic/265216-turn-list-of-events-into-a-calendar-layout/#findComment-1359209 Share on other sites More sharing options...
Drummin Posted July 5, 2012 Share Posted July 5, 2012 I just made one as PFMaBiSmAd suggested, so if you get stuck or want a copy, PM me. Quote Link to comment https://forums.phpfreaks.com/topic/265216-turn-list-of-events-into-a-calendar-layout/#findComment-1359480 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.