The development of veerMe required not only the writing of client-side Javascript fo the more obvious funtionality and communication with the Google Maps API but splatterings of server-side code in the form of PHP to save and retrieve different types of data.
This post is just a quick reflection on the methods used to achieve the necessary functionality.
Saving Routes
Once a user has created their journey they can save it as a link to then access again at a later date.
Click here to view commented PHP for this action.
Viewing Routes
eg. http://veer.me.uk/r/?route=pneakv
To retrieve the route information I use the GET super global variable function to retrieve the ref value from the URL the user entered then et up a database query to get the information before feeding it into JS. This page was rushed (it was close to hand-in!) otherwise the JS would not be inline. I’m unsure as to whether or not there might be a better way of dynamically setting JS variables using PHP, if there is please let me know.
Click here to view commented PHP for this action.
Rating Suggested Locations
I previously blogged about finding a solution for a discreet location ranking system. My solution was to generate a rating for each location that was essentially just a percentage of times a place was added to a route compared to how many times it was suggested.
For example, once a user decides to add a point of interest to a route a JQuery AJAX function posts to a seperate PHP page the id of the point of interest and a boolean indicating whether or not it has been used.
Click here to view commented PHP for this action and see how it then deals with the posted information.
Third Party APIs
Because of security restrictions it is not possible to connect to XML files on different domains. The easy workaround for this is to use curl. Click here to see code.
———————————————
That’s all for now, its probably the most interesting PHP use from veerMe but there are a few more examples.

