What's a dynamic website? In this course, you will learn how to leverage what you already know about creating static Web sites with HTML along with some new PHP and MySQL skills to create a Web site to meet various needs. By adding PHP, you can customize Web pages to show different information depending on what is input into them. PHP is a language that can be used within HTML, whereas MySQL is a database that can hold data for PHP to pull information from.
If you've been creating Web pages using HTML, PHP and MySQL can take your development skills to the next level. You can create data-driven dynamic Web sites that can stand on their own -- both for Web visitors and the Web site clients. If you're creating a dynamic site for your business or organization, you can allow others in the organization to make updates to the site without giving them full control.
There are two basic types of Web sites: static and dynamic. In most basic terms, a static Web site is one in which the data never changes and a dynamic Web site appears different depending on inputs of each person viewing it.
A Web site can use a combination of static and dynamic pages, but it's still considered a dynamic Web site.
A static Web site is contains information that may change, but not constantly. However, if the Web pages do change, they change for everyone viewing the site in the same way; in other words, the Web pages remain static to each person viewing them. Static Web pages remain the same no matter who logs on, when the user logs on, where the user is on the Web site, or what a person decides to do once there.
In contrast, a dynamic Web site is database driven and is constantly updated (think eBay). You can search and sort for specific items in different ways, or you may even be offered suggestions based on your previous viewing history.
To create a static Web site, pure HTML (Hypertext Markup Language) is used. HTML is completely text based and relies primarily on content within the file being called. In contrast, a dynamic Web site uses more sophisticated coding and can be connected to a database such as MySQL. Depending on selections made on the Web site or other variables, such as username, date, time, and so on, different Web pages appear at different times.
What's PHP?
In this course, you'll use both PHP and MySQL to create a dynamic Web site that calls information from a database to show information that the user chooses. You'll also create an administration page for someone (the customer or other employee) to update and manage the Web site without needing to know any programming at all.
To create dynamic Web sites, a variety of programming languages can be used. The following list briefly introduces these technologies and compares them to PHP:
PHP ( PHP: Hypertext Preprocessor): PHP is a structured, server-side language (and one of the main focuses of this course). This means that it has rules (structured) and all of its code is run on the server. It can be run on Unix- or Windows-based servers and can integrate with databases, such as MySQL, PostGres, and others.
The name PHP actually stands for PHP: Hypertext Preprocessor. I know it's weird, but I only report it, not create it!
ASP ( Active Server Pages): ASP is a proprietary system used only on Microsoft IIS (Internet Information Services) servers. It's not a language like PHP, but uses VBScript (Visual Basic Script) or JScript to create and run ASP. All code is run on the server. The pros of using ASP include the ease of learning VBScript if you already know how to program in Visual Basic. If you're running a Microsoft server, it's easy to get up and running, but ASP is said to be slower, more cumbersome, and less stable than PHP. Plus, there are a limited number of components built into ASP, so you may end up buying additional components if you need to use features not included. And of course, IIS servers tend to be more expensive than Unix-based servers are.
CGI/Perl : Perl is a high-level programming language, originally used to build and test programs. Perl is a very tried and true language. It's been around since the late 1980s. The flexibility and complexity of Perl makes it easy to write code that another author or coder may have a hard time reading. PHP has a less confusing and stricter format without losing flexibility. PHP is easier to integrate into existing HTML than Perl. PHP has all the good functionality of Perl, such as constructs, syntax, and so on, without being as complicated as Perl.
ColdFusion : ColdFusion is both a language and a database. It's an integrated system designed for nonprogrammers; therefore, it's generally easier to get started with, but may limit growth at some point. PHP, on the other hand, requires more programming knowledge initially, but it's faster and more efficient for complex programming tasks and trying out new ideas. PHP is generally referred to as more stable and less resource intensive as well.
JavaScript : JavaScript is a client-side programming language. This means that the code runs on the computer of the person viewing the Web site. The advantage of a client-side programming language is the speed and lowering of the server's work. Its biggest disadvantage is the unpredictability of the systems that may be running your code. Some people have JavaScript turned off on their system and older computers may not be able to handle it.
Each of these programming languages has its strengths and weaknesses. By using PHP (or other server-side language) to write your pages, you know that what works on your system will work on anyone's system (as far as coding goes) because you're running the code on the server, not on your local machine.
In fact, you can't see PHP code in any PHP page unless you have access to the server. When a page is served that contains PHP, the server processes the instructions and sends normal HTML to the client requesting the page.
PHP is inserted within the HTML code, and then stripped out as it's processed, so a page with PHP in it looks like this when you create it:
<html>
<body>
Today is
<php>
.
</body>
</html>
When viewed as a source file from the computer requesting the file, however, it looks like this:
<html>
<body>
Today is Saturday, the 10th.
</body>
</html>
And of course, on-screen, it will look like this:
Today is Saturday, the 10th.
However, the PHP code provides the current date when the file is run, whereas the HTML file still says the same date. Thus, the power of dynamic Web sites!
PHP is most commonly found on Apache and Unix Web servers, but it can be installed on IIS, Netscape Enterprise Server, and others. If you don't have your own server, you can easily set up an account at any number of Web hosts. Ask if PHP is installed, as well as MySQL (which is covered in the next section of this course).
Plan it
Even before you get your Web site, you need to start planning for it. This section gives you pointers on where you might host your Web site, but even before you set it up, you need to plan what you'll be doing.
In this course, you'll create a demo Web site for a property management company (this is a company that offers properties for rent). To that end, you need to consider what the company needs for its Web site and how you plan to go about getting what it needs. You need the following:
Static home page and other various pages: These can be created in HTML and are beyond the scope of this course other than to note you may integrate static and dynamic pages in one Web site.
Dynamic admin page: This page needs to be password protected and will allow the Web site owner (a noncomputer person who is the property manager) to manage his properties. As such, this page needs an interface to list properties currently on the Web site, so the properties can be active or inactive. The property manager will have rentals on a recurring basis, so once the property is in the database, it will be available for future activation when it's available for rent again. In addition to activating existing properties, the property manager needs to be able to edit text fields, upload photos, add new properties, and delete old ones (that he no longer manages).
Dynamic properties page: This page is for the public and allows visitors to view properties currently for rent and search by preferred needs, such as two or three bedrooms, city, and preferred rent amount.
Each Web site you create will have different purposes and needs, but before anything else, you need a plan. Start with the needs of the visitors and the needs of the company. Understanding your goal shapes each future decision.
If it's your own company, you can simply manage your Web site through the backend (as you'll learn when you set up your database). However, this example assumes you're creating a Web site that nontechnical people will manage. If you approach your Web site as if you'll turn over all management of the site to nontechnical people, you can later replicate the site for another client.
In implementing any plan, if this is a brand-new Web site, start by creating the look of the Web site based on what will work best for your visitor demographics. If it's an existing Web site, you can take the existing look, and then add the dynamic code to it. Either way, the procedure is to create the static look first, and then code the dynamic portion of the site.
One other way to create a dynamic Web site is to create the code without the site, displaying database information on a plain white page, and then adding the Web site code around it. This allows the graphic and design people to work on their portion, while the programmer works on her section, and then integrates into the correct look.