Events Calendar - Where to begin?

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
gx94ts
Forum Newbie
Posts: 2
Joined: Thu Nov 24, 2005 6:47 pm
Contact:

Events Calendar - Where to begin?

Post by gx94ts »

I am as green as they come; new to PHP, MySQL, and forums. However, I am looking for guidance on where to begin. I am helping a friend re-build her website and will need to develop a database driven Events Calendar. Does anyone have any suggestions on where to begin?

I am currently reading PHP and MySQL by Wellington and Thomson. Any suggested readings?
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Okay, you're onto something fairly large if this is the first thing you're doing with PHP/MySQL. However, you'r in the right place. :) Reading tutorials will surely help you, but make sure they're relevant, you don't want to be reading PHP/MySQL user login tutorials when you're working on a calendar. If I were you, I'd look into various time functions of PHP and MySQL, and figure out how to put them together. In fact, I'll suggest the following structure for your database:

Date | Event
____________________________________
112405 | evilmonkey writes this message

Date will probably not be 112405, it'll be probably be a UNIX timestamp, or some kind of PHP formatted date, but it doesn't matter. What you can then do with PHP is loop through the dates, checking if there's something stored in the database for that date. For instance: (if you're using 11/xx/05 format for the date, your loop for the month of november will look like this:)

Code: Select all

<?php
$db = mysql_connect("localhost", "username", "passwprd");
mysql_select_db("your_db", $db);
for ($i=; $i<=30; $i++){
   $result = mysql_query("SELECT `event` FROM `your_table` WHERE `date` = 11".$i."05", $db);
   $events = mysql_fetch_array($result);
   echo $events['event'];
}
?>
WHen the value of $i reaches 24, echo will spit out "evilmonkey writes this message". Again, this is just the idea, it's horrible to use dates like this when there's a wealth of PHP and MySQL features at your disposal. Study the manual, if you have any more questions, we'll be happy to help you. But that's the general idea.

Good luck.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

http://www.google.co.uk/search?q=php+calendar+tutorial

Take your pick :)

If you are having problems, post on here and someone will try to assist :)
Post Reply