How to build a basic Facebook style ‘check in’ function using PHP and AJAX.

This is a basic ‘check in like’ tutorial that saves the current latitude and longitude, along with a timestamp. This can be achieved through using Geolocation, Ajax and PHP.

I’m using Twitter’s Bootstrap theme, so for it to look fancy, include the Bootstrap theme’s files on your check in page below.

The first step is to locate the user through the Geolocation function. This finds the user’s latitude and longitude and uploads it to a table in the database.

Continue reading

Using LEFT OUTER JOIN correctly with two predicates.

On a little project I’m working on, I needed to LEFT OUTER JOIN table ‘a’ with table ‘b’ – “Show the user all the societies they have not yet joined.”, but I had two predicates to work with, a user ID.

My table ‘a’, has a list of societies a user can join, within table ‘b’, the user’s chosen societies are stored, with the foreign key being the ID of the society. With each user being unique, my query had to take this into account. Continue reading

Recommended database.php configuration for MAMP/CakePHP 2.x

As there seems to be an error with my MAMP running on the default Apache port (80), I switched to the MAMP Apache/MYSQL default ports (8888/8889). Once I swapped the configuration over, my CakePHP application could no longer connect to the database.

After a bit of messing around/tweaking, I finally got it to work. Here is the recommended CakePHP 2.x Database.php code: Continue reading