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
https://forums.phpfreaks.com/topic/58044-solved-calendar-database-design/
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.

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.