Page 1 of 1

Events Calendar - Where to begin?

Posted: Thu Nov 24, 2005 7:38 pm
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?

Posted: Thu Nov 24, 2005 8:52 pm
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.

Posted: Fri Nov 25, 2005 3:12 am
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 :)