Jump to content

turn list of events into a calendar layout


deansatch

Recommended Posts

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?

Link to comment
Share on other sites

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.

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.