The Plain State Site

A stripped-down example of a dynamic website, with all the source code.

This example website is provided for students attempting to build their own 50 States Project sites.

It is a very "plain" website, with only the barest minimum of styling, so you can concentrate on the dynamic PHP/MySQL coding that makes it all work.

Styling has been kept to a minimum:

Naturally, when you build your own sites, you will want to make them fancier than this one. But this one is kept plain so you can learn the PHP with as little confusion as possible.

This whole site uses only 8 files!

There are eight text files which make this entire site: one CSS file, four PHP pages, and three PHP includes. These files are all together in the root directory. The links below take you to all the source code for these eight files. The PHP files contain copious comments to explain what the code is doing every step of the way.

An external style sheet used by all the pages
The home page (it's the page you are reading right now)
The page that gives details about a selected state (it reads a query string to determine which state it is displaying)
A special page that displays the flags of all the states.
A special page that ranks the states by area.
The code that defines all the PHP functions, included by all the pages
The code that defines all the PHP variables and connects to the database, included by all the pages
The code that makes the sidebar div, included by all the pages

Download all of the source code files as

If you look at the source code for all eight files, you can learn everything about how this site uses PHP and MySQL to generate pages dynamically from the database.

You can even use the same code on your own site, making whatever changes are needed to display your own design.