Portfolio: PHP / MySQL

A.M.P.PHPMySQL

AMP or Apache MySQL PHP is a collection of open-source packages designed to facilitate hosting websites on a server, accessing server databases, and generating dynamic HTML content. PHP is a server side scripting language, that can dynamically generate HTML content before it is sent over the internet to the user’s computer. MySQL is a Structured Query Language used to access relational databases. MySQL allows for quick access to large amounts of stored data in a remote database. PHP works seamlessly with MySQL to present the results from the database query in an easy to read format for the client’s browser to display.

PHP / MySQL

This section highlights utilization of PHP to access MySQL databases and to parse that data into XML tags for structured formatting that the user’s browser can understand.

CrowdSource ScreenShot

“Crowd Source”

Tags: PHP MySQL ActionScript Flex PixelBender Carrara

“CrowdSource” is an experiment in crowdsource story telling. This app uses 20 images from a children’s book I wrote and illustrated. This experiment allows users to improve upon my amateur storytelling abilities. The users are able to edit, revise, or completely alter the text from the previous versions.

In this example, all previous user’s edits are retrieved using PHP to comunicate through MySQL to the site’s server. Then some more PHP parses the MySQL data into an XML format that ActionScript can read. Lastly, the user’s edits are saved using the PHP $_POST method and MySQL to write the data to the story book’s server’s database.

This site features:
View More...
  • Retrieving data from the server with PHP through MySQL.    View Code Sample.
  • Parsing the retrieved data with PHP into XML.    View Code Sample.
  • Retrieving user data from the ActionScript site with PHP.    View Code Sample.
  • Writing the user data to the server with PHP through MySQL.    View Code Sample.

Launch website in a new window.
View source code in a new window.

ImageMagick

Beyond accessing databases, PHP allows processing on the remote server. ImageMagick is a command line image processing suite. Akin to Adobe’s Photoshop, but without the nice user interface. With ImageMagick one can preform all sorts of image adjustments before the image ever gets sent to the client’s computer.

phpResize

“PHP Image Resize”

Tags: PHP ImageMagick jQuery

“PHP Image Resize” is a sample of code that utilizes ImageMagick through PHP. It is impractical to optimize a photo for best display in all browsers ahead of time. However with ImageMagick and PHP we can dynamically configure an optimal image at runtime. In this example I use jQuery to send the maximum width and height of a user’s screen to a small PHP script. Leveraging the power of ImageMagick through PHP I dynamically down-size a large image to fit what ever width and height the client is using.

Why would I do this?

This allows for the server to download to the clients computer the optimal file size to fill the client’s browser window. For example on my personal computer, this script converts a 5.5mb 3000×2250 .png file to a 54kb 1032×645 .jpg file. Much more optimized for downloading! (While still looking good fully enlarged on my display screen.)

"PHP Image Resize" performs the following tasks:
View More...
  • Detects the width and height of the client’s display screen.
  • Sends the width and height to the PHP script in the URL of a GET request.
  • PHP shrinks the requested image down to the user’s display resolution.
  • PHP converts the outputted image to a JPEG and drops its quality to a reasonable 50%.
  • PHP returns the resized jpg converted image to the calling document.
  • jQuery adjusts the width of the returned image to the width of the browser, maintaining aspect ratio.
  • jQuery will always maintain the maximum width of the image for the size of the browser.
View Code.
HTML Document and jQuery Script
imageLoad.php
Launch demo in a new window.
Viewport ReSize

“Image Conversion”

Tags: PHP ImageMagick

“Image Conversion” is a sample of code that utilizes ImageMagick through PHP. The sample comes from a larger program that allows a user to upload an image. The PHP then verifies the image type, creates a thumbnail, stores it, and records all the information into the server’s database.

"Image Conversion" performs the following tasks:
View More...
  • Verifies that the uploaded file is of an acceptable image file.
  • Calculates the dimensions of the image.
  • Crops the image to a user specified ratio.
  • Shrinks the image down to a user specified width and height.
  • Optimizes the image resolution for quality vs download speeds.
  • Returns the new filename and location of the converted uploaded image.
  • Creates a thumbnail of the converted image as well as returns the filename and location.
View Code Sample.

Other Projects

Below are some other PHP samples of code.

phpResize

“PHP Mobile Redirect”

Tags: PHP

“PHP Mobile Redirect” is a simple PHP script that will redirect to a mobile site if the device the user is using is not a desktop or laptop computer.

"PHP Mobile Redirect" performs the following tasks:
View More...
  • PHP checks that a ‘notMobile’ value is not passes in the URL of a GET request. If there is, bypass the mobile check.
  • PHP checks that $_SERVER[‘HTTP_USER_AGENT’] is not NULL.
  • PHP preg_match tests $_SERVER[‘HTTP_USER_AGENT’] vs known mobile types.
  • PHP redirects if a known mobile device is detected.
View Code.

Leave a Reply

Your email address will not be published. Required fields are marked *

*