Site Cloner PHP Script
Bargain Hunter PHP Script
Job Hunter PHP Script
Site Login and Access Control PHP Script

Real World PHP / mySQL Coding Example

Calendar Application With Database and Google Integration

You decide to make a custom calendar integrated with Google calendar. In other words, the calendar will grab data from a database and Google Calendar. You explore and discuss the options, and it comes down to a custom script, modified script or purchased script. After browsing the various options, the decision came down to a custom calendar script that will integrate with Google. You surf the web and find this JQuery Plugin called full calendar. The plugin comes with good documentation and it leaves room to do what you want. But, it needs plenty of work and adjustments to make it function exactly as desired.

Initially, the first step is to download the files and test them in wamp or Firefox. After looking into the files, you
attempt  to set it up to work seamlessly with Google Calendar. But, it is not outputting as desired. After a short investigation, adding ‘<script type=’text/javascript’ src=’fullcalendar/gcal.js’></script>’ into the head of the file made things work properly. Then, changing the extension(.html) to index.php helped make things flow perfectly. After all, this is a php/mySQL script and we will need to work with a mySQL database. Then, the files were reordered so that the files of interest were in the root folder and css and js files were in the next level of folders. In the end, we created 4 files; index.php, edit_calendar.php, events.php and connect.inc and used the remaining cs and js files which came with Fullcalendar.

Seeing out it output with Google Calendar laid down a lot of groundwork for database preparation. But, some users will not use Google calendar. Therefore, the script must be made to work with a database as well.

 In the end, we set up two database tables for the sources and one for the entries. The sources tables had two entries; one for the the Google calendar xml feed and one for a local file which made an array of the various entries for the calendar.

Then, you customize the a few pages so that entries output and you can add, edit, update and delete entries. With a little intensive date coding session; you end up with a robust system to make and adjust appointments with exact dates and times.

Then, you test to confirm the desired results. After creating, updating, editing and deleting a few entries; you have a solid calendar.  

Now that the scripts works, you find change the file order around so that the index.php


Coding Summary:

File: connect.inc
The file connect.inc was added in order to connect to the ABOOK database.

File: index.php
The file json.html became index.php

The script ‘<script type=’text/javascript’ src=’fullcalendar/gcal.js’>’ was added to the head tag

A query was written to make an array of the urls for which to get calendar events. At nearly the same time, the database table was made to hold entries which display on the calendar.

Near line 43 we loaded the url sources for events we want to publish by adding eventSources: [<?php echo implode(“,”, $urls); ?>  ]

A form was created to allow for adding events into the database.

File: File: events.php
The file json-events.php became events.php

The static array and commented it out and made the entries come out dynamically with the events array.

File: edit_calendar.php
This file was used to edit and delete entries.