Facebook Logo Wordpress Logo Twitter Logo

PHP/SQL Overview

1. What is PHP?

PHP is a server side scripting language that enhances an HTML web page. It allows a web page to collect and process data, check user permissions and generate dynamic page content. PHP is open-source and best of all, free. It runs on almost all web servers and operating systems.

2. Describe briefly the history of PHP.

PHP was developed in 1995 by Rasmus Lerdorf, a Danish programmer to help him manage his own web page. PHP stood for Personal Home Page but it has evolved to mean an acronym for Hypertext Preprocessor. Lerdorf re-wrote his original Perl scripts in C language, joined forces with a few other programmers and released an official version of PHP 3.0 in 1997. Public testing and development on this open source scripting language has led it to evolve with enhanced security features and improved support for Object Oriented Programming. PHP language is now available to run command line scripts to carry out useful tasks. PHP has become the world's most popular web scripting language used by over 20 million web sites.

3. Describe general usage of PHP like server-side scripting, command-line scripting, and client-side GUI applications.

Server-side scripting is a block of PHP code nested in a regular HTML page. This code must begin and end with the tags, . As an example, to add a short calculation to a HTML page, one would write: $years = 20; $days_per_year = 365; $days_old = $years * $days_per_year; echo $days_old; ?> An example of command line scripting on a Windows OS would start by having the user click the Windows icon on the bottom left of the screen and entering "cmd" in the search box. A window will open containing white text on a black background. Now you simply type in the PHP lines of code you wish to execute one at a time and press "Enter". Alternately, you could save several lines of code into a .php file, open the "cmd" window and execute/run that .php file. An example of a commonly used client side GUI application would be the use of a form. A form is a sort of container used by a web client to give information to the server usually including your name, a comment or question and the client's email address. In the right column you will see a small section of code that would be imbedded into an existing HTML page to construct and process a form:

4. Explain basic PHP syntax.

PHP syntax is very similar to C,C++, Java and C# making it easier for an experienced programmer to quickly learn PHP. There are a few exceptions such as variables. They must be used in conjunction with a $ sign. Ex: $mynumber = 5;. Most commands will be written in lower case such as "if", "else" and "while". Blocks of code use the familiar curly braces "{" and "}" to indicate their start and end. Each individual complete line of code will end in a semi-colon. Functions/Methods work similar to C, C++, Java and C# where they accept input variables and may have a return value. Unlike C, C++, Java, C#, PHP functions do not accept the return data type defined in the function's heading.

5. Explain how PHP can be applied to a website.

PHP can help a web designer take a rather ordinary website and make it into an impressive interactive experience by using some of PHP's functionality.

  • PHP and GD library may be used to create and edit graphics. You can resize, rotate and greyscale images. You can even create your own photo gallery.
  • PHP can execute mathematical formulas. It can also show you the system clock or current date and time.
  • PHP can help the designer collect information from the client. PHP will allow a user to enter information that gets sent to the web server so the client can "consume" a web service or simply send an email.
  • PHP works with a free database called MySQL. Web Designers can interface with MySQL to populate a DB table, search for a record or display a formatted report.


PHP Syntax:

if (isset($_POST['stage']) && ('process' == $_POST['stage'])) {

} else {

PHP Filter Example:

$int = 123;
if(!filter_var($int, FILTER_VALIDATE_INT))
echo("Integer is not valid");
{ echo("Integer is valid");

MySQL Overview

1. What is MySQL?

MySQL is an open source, cross-platform, free database. MySQL can be used for home or office applications and includes most if not all database features found in expensive commercial databases such as Oracle and SQL Server.

2. Which of the MySQL Admin and Development Tools explained in the article [do] you recommend? Why?

Having used database admin/development tools for years, I have a pretty good idea of what is needed and what may be just bells and whistles. I’ll call these database admin/development tools, “DMC “ (Database Management Console) for this article.

A good DMC must be able to assist in building and executing all SQL queries and non-queries. Queries for example are SELECT statements and non-queries usually refer to INSERT, UPDATE and DELETE commands. The DMC should be able to open and save user defined SQL statements/commands.

A DMC should be able to process SQL triggers and stored procedures. It should present a view that makes sense to the average user. The view should have icons or symbols and should be set up in a hierarchical order.

Since managing a database is a very important job, tools to do this should be available. The DMC should have a lot of default basic values to make setting up the database as easy as possible. Managing a database requires monitoring the databases themselves for size, speed and backup schedules. Managing a database also includes database policies, users and permissions.

Although it’s not required but a very nice tool to have, a DMC including a section to visually design relational databases makes your job a lot easier if assigned the task of building from scratch.

Finally, a solid DMC should be able to generate reports. A customer may wish to have a graphical display of daily/weekly/monthly data changes and trends. To me, having the DMC as a standalone application or available as web page wouldn’t matter either way if they both provided the same functionality.

The DMC I would select based solely on the article and links to the publisher’s web site would be EMS SQL Manager. EMS claims to have all the functionality I listed above and includes other management features that are important but not used as often such as Import/Export database. The GUI looks clean and orderly. EMS appears to have an edge over the other good DMCs.

MySQL Open/Cose Connection:

$con=mysqli_connect("example.com","peter", "abc123","my_db");
// Check connection
if (mysqli_connect_errno($con))
echo "Failed to connect to MySQL: " . mysqli_connect_error();



(db connection already made....)
$result = mysqli_query($con,"SELECT * FROM Persons");

while($row = mysqli_fetch_array($result))
echo $row['FirstName'] . " " . $row['LastName'];
echo "";



(db connection already made....)
// Check connection
if (mysqli_connect_errno())
echo "Failed to connect to MySQL: " . mysqli_connect_error();

mysqli_query($con,"UPDATE Persons SET Age=36
WHERE FirstName='Peter' AND LastName='Griffin'");


JavaScript Tutorial:

JavaScript Function Example:

function showEM(userName, emServer)
userName = stringReverse(userName);
emServer = stringReverse(emServer);
var emLink = userName + "@" + emServer;
document.write("a href='mailto:" + emLink + "'");

                jQuery Examples:

Google Report GIF

Site Management Tutorial:

Web Site Management Icon

Photoshop Picture Restoration

                               Before:                                                                          After:

Before and After Photo

Website Topics: