Calendar Help needed / View by Day/ View by Week

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
WizyWyg
Forum Commoner
Posts: 92
Joined: Tue Aug 06, 2002 7:20 pm

Calendar Help needed / View by Day/ View by Week

Post by WizyWyg »

Working with PHP and Mysql.

Im playing around with creating an Events/Reservation Calendar, and I can get the "month" view down, but I can't find anything to show how to do "view by week" or "view by day". I've looked over several tutorial sites and even at PHP.net and Mysql.com for any information regarding how to create a calendar system and be able to select different views for it.

Can anyone provide links or faqs/tutorials/hints on how to construct a page so that it pulls information from a database containing events or reserve information ( title, desc, begin time, end time, etc) and be able to view the events/reservations by week and then by (or for) that day?

Im looking for answers on how to display:

1. For Week View:
Days of that week across the top
and HOURs of the day on the left side
Ie
Monday (m/day) | Tuesday (m/day)| Wed (m/day) | Thurs (m/day) | Fri (m/day)
9
9:30
10
10:30

2. For Day view:
(Weekday/m/day)
9
9:30
10
10:30

And for each if an event happens between a certain time, it will display it (highlighted or colored etc) between those hours
Ie
Meeting for Team 1 on XX/XX between 9 am - 12 pm for both Day and Week view

XX/XX
9 Team 1 Meeting
9:30 |
10 |
10:30 |
11 |
11:30 |
12 |

If someoen can understand what Im looking for, Im just in search of any online tutorials/hints that can show exactly how these can be achieved. ]

Thanks for your time

Dani
WizyWyg
Forum Commoner
Posts: 92
Joined: Tue Aug 06, 2002 7:20 pm

Post by WizyWyg »

41 views? and no one has a link to anything online that covers this?

Just links. Im not looking for full blown codes; I only have tutorials on making calendars, but nothing that shows you how to display by day or by week, with hours in a day in a grid format.

A book perhaps? one that explains how to display hours in a day, etc...
User avatar
EvilWalrus
Site Admin
Posts: 209
Joined: Thu Apr 18, 2002 3:21 pm
Location: Springmont, PA USA

Post by EvilWalrus »

I don't know offhand of anything (without searching), but Google is your friend.
WizyWyg
Forum Commoner
Posts: 92
Joined: Tue Aug 06, 2002 7:20 pm

Post by WizyWyg »

EvilWalrus wrote:I don't know offhand of anything (without searching), but Google is your friend.
Google in this case was no friend. I can't find anything that explains how to do this. But there are "other" applications that do.

I've looked under:
Calendar Tutorials php (which basically only gives you how to create a calendar)
Week View Calendar tutorial php (which basically only gives you how to create a calendar ; nothing on viewing by week)
Day View Calendar tutorial php (which basially only gives you how to create a calendar; nothing on viewing or getting hours in a day to display)


Or else can someone walk me through on how to go about creating it so that we can have acutally something to show how to get this done?
User avatar
EvilWalrus
Site Admin
Posts: 209
Joined: Thu Apr 18, 2002 3:21 pm
Location: Springmont, PA USA

Post by EvilWalrus »

Well, we're by no means going to write your code for you. If you can find combined ideas of what you want to make, there's nothing we can do but pat you on the back and wish you good luck. That's you job as the programmer, to create and customize your own scripts. Use other people's ideas, and combine your own with it.. Trust me, it works.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

But of course we're willing to share ideas if you're going to write the script yourself. Simply ask your questions. You will increase the probability of getting help if your post somehow has the form
"I want to do <subject>. My concept is <step 1..n>. I managed to get <step 1..m> working but have problems with step <m+1>.
Thought <code snippet> will do but it doesn't. I guess <link to man-page you've read> has to do with it but I can't figure out how to use it. Please help"


This is a tip from somewhere in the middle of the concept; I hope it will not confuse you ;)
For each view you have to query all events within a certain interval. For the current week this would be "all events between 13.4.2003 and 19.4.2003". That's exactly what you can tell mysql.

Code: Select all

SELECT <fields you need> FROM <tablename> WHERE begin_time BETWEEN '2003-04-13 00:00:00' AND '2003-04-19 23:59:59'
is a valid query.
Now you can order the result by the time the events begin

Code: Select all

SELECT <fields you need> FROM <tablename> WHERE begin_time BETWEEN '2003-04-13 00:00:00' AND '2003-04-19 23:59:59' ORDER BY begin_time
maybe you will find

Code: Select all

SELECT <fields you need> FROM <tablename> WHERE begin_time between '2003-04-13 00:00:00' AND '2003-04-19 23:59:59' ORDER BY EXTRACT(HOUR_SECOND from begin_time), TO_DAYS(begin_time)
more useful; maybe not, haven't thought too much about it. Might be useful if you're using tables to display the events. It will return the recordsets ordered by time (the horizontal axis of your table) before date (the vertical axis) and as this is the order of creating the table it might(!) be smart.
User avatar
Zoram
Forum Contributor
Posts: 166
Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:

Post by Zoram »

I can't say that i know any tutorials that are going to help you but if you can set up a nicely formatted table for your weekly view then it all comes down to querying for events to see if there are any.

You could do the main table something like...

Code: Select all

<table border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="75">&nbsp;</td>
    <td width="100"><div align="center">Monday</div></td>
    <td width="100"><div align="center">Tuesday</div></td>
    <td width="100"><div align="center">Wednesday</div></td>
    <td width="100"><div align="center">Thursday</div></td>
    <td width="100"><div align="center">Friday</div></td>
    <td width="100"><div align="center">Saturday</div></td>
    <td width="100"><div align="center">Sunday</div></td>
  </tr>
  <tr valign="top"> 
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td><div align="center">9:00</div></td>
        </tr>
        <tr> 
          <td><div align="center">9:30</div></td>
        </tr>
        <tr> 
          <td><div align="center">10:00</div></td>
        </tr>
        <tr> 
          <td><div align="center">10:30</div></td>
        </tr>
        <tr> 
          <td><div align="center">11:00</div></td>
        </tr>
        <tr> 
          <td><div align="center">11:30</div></td>
        </tr>
        <tr> 
          <td><div align="center">12:00</div></td>
        </tr>
        <tr> 
          <td><div align="center">12:30</div></td>
        </tr>
      </table></td>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td bgcolor="#000066">&nbsp;</td>
          <td>&nbsp;</td>
          <td bgcolor="#0033CC">&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td bgcolor="#000066">&nbsp;</td>
          <td>&nbsp;</td>
          <td bgcolor="#0033CC">&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td bgcolor="#000066">&nbsp;</td>
          <td bgcolor="#3366CC">&nbsp;</td>
          <td bgcolor="#0033CC">&nbsp;</td>
          <td bgcolor="#3333CC">&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td bgcolor="#000066">&nbsp;</td>
          <td bgcolor="#3366CC">&nbsp;</td>
          <td bgcolor="#0033CC">&nbsp;</td>
          <td bgcolor="#3333CC">&nbsp;</td>
          <td bgcolor="#996600">&nbsp;</td>
        </tr>
        <tr>
          <td bgcolor="#000066">&nbsp;</td>
          <td bgcolor="#3366CC">&nbsp;</td>
          <td>&nbsp;</td>
          <td bgcolor="#3333CC">&nbsp;</td>
          <td bgcolor="#996600">&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td bgcolor="#3366CC">&nbsp;</td>
          <td>&nbsp;</td>
          <td bgcolor="#3333CC">&nbsp;</td>
          <td bgcolor="#996600">&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td bgcolor="#3366CC">&nbsp;</td>
          <td>&nbsp;</td>
          <td bgcolor="#3333CC">&nbsp;</td>
          <td bgcolor="#996600">&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td bgcolor="#3333CC">&nbsp;</td>
          <td bgcolor="#996600">&nbsp;</td>
        </tr>
      </table></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
There's some other things you could probably do but that's the idea i was having... you'd want to use images and other stuff so that it could print right though.
WizyWyg
Forum Commoner
Posts: 92
Joined: Tue Aug 06, 2002 7:20 pm

Post by WizyWyg »

Can the times be generated dynamically instead? If i have them static, how will I be able to call from the dB events for that time period? And how will that help repeatable events (ie meeting every thursday?).

Is there a book that shows how to do this?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

WizyWyg
Forum Commoner
Posts: 92
Joined: Tue Aug 06, 2002 7:20 pm

Post by WizyWyg »

Thanks Volka, but already looked at those two, and they aren't what I need (and also very cumbersome).

What Im in need of is more like:

http://sourceforge.net/projects/mrbs/

but, the drawback on that is they do not implement a "authentication"
system (ie obtaining pw/user from db instead of through ip) ; which is how they have it set-up. Their' documentation doesn't address DB user/pw but use Ip, Ldap (not installed), and others that Im not familiar with. Any ideas on how i can go about changing the way its setup in authentication?
Post Reply