Jump to content

[SOLVED] Calendar Database Design


Carterhost

Recommended Posts

I've been racking my brains over this one, searched t'interweb countless times, and keep coming up with things that are too complicated.

I want to build a calendar display page, with dates "blocked out" to signify that i'm busy.

I want to be able to select sate ranges that i'm busy, and to be able to delete blocks if my schedule frees up.

 

What I can't figure out is the best database design for this.  How would it be best to insert a date range into a database, and pull it out again?

I was thinking along the lines of:

 

ID          START                END

 

For which each field contains a block of unavailable dates.

 

If I want to display say, 3 months, how would I select just the date blocks within those months?

 

 

Link to comment
Share on other sites

It is Internet.

 

And how do you want to display the calender?

You can use a simple loop:


while($data = mysql_fetch_array($query)){
if ($data['blocked'] == TRUE){
echo '<p class="red">' . $data['time'] . '</p>'; 
} 
else {
echo '<p class="normall">' . $data['time'] . '</p>';  
}
}

 

Or you could just edit that structure into a week and change the loop a bit:


while($data = mysql_fetch_array($query)){
echo '<tr><td>' . $data['time'] . '</td><td>' . $data['time2'] . '</td><td>' . $data['time3'] . '</td><td>' . $data['time4'] . '</td><td>' . $data['time5'] . '</td><td>' . $data['time6'] . '</td><td>' . $data['time7'] . '</td>'; 
}

 

Just put the if statements in.

Link to comment
Share on other sites

I think I have it, I'm going to break it down within the database:

 

ID | START_DAY | START_MONTH | START_YEAR | END_DAY | END_MONTH | END_YEAR | COMMENTS

 

Then I can select each busy block per month/year, and output the day as a class change on my calendar CSS.

 

If noone can see any problems, I'll give it a go!

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.