"Build a Basic PHP Website (2018)" was retired on December 10, 2019. You are now viewing the recommended replacement.
- PHP
- Beginner
About this Course
This project will show you how to build a simple website using the PHP programming language. The web site, a media library, will let you organize and display your Books, Movies and Music. You could easily use this project to create a website that lets you organize and display any type of item: Branch Locations, Products, Services, Events, even Courses like we have here on Treehouse.
What you'll learn
- Organizing and Displaying Inventory
- Reusing Code
- Email and Form Data
Building a Media Library in PHP
Our media website will have a number of pages, but the pages share a few common elements like the top navigation menu and the footer. We’ll build these shared elements into a set of template files, using basic programming concepts like variables and conditionals to make it all work.
11 steps-
Setting Up the Project
3:31
-
Using PHP Code on Our Site
3:09
-
A Simple PHP Example
1 objective
-
Including the Header
5:32
-
Including the Footer and Adding Additional Pages
3:19
-
Basic PHP and Including Files
5 questions
-
Using Variables for the Title Tag
3:24
-
Working with _GET Variables
5:10
-
Variables and Conditionals
6 questions
-
Adding Active States to the Navigation
4:29
-
Variables and Conditionals
3 objectives
-
Extra Credit
Add another page to the menu for something like "Company Information." You'll need to complete the following steps:
- Create a new PHP file for the page, making sure to set the $section variable.
- Modify header.php to display the new menu item, making sure that it is underlined when someone is on the new page.
- Create an icon for the menu item.
- Modify the CSS file to display that new icon, as well as to make room for the extra item in the menu.
Listing and Sorting Inventory Items
Our media library contains quite a bit of information, too much to fit in simple variables. A PHP array will be perfect for the task, and we’ll explore all the ins and outs of working with arrays to store sets of related data. We’ll also use the data from the array to populate our category pages that shows a list of all the media in our catalog.
We want to have separate pages for the different categories of media items, but the layout should be the same on each of these pages. We’ll work with PHP functions, blocks of code that can be called from other blocks of code, to make sure that media items are displayed the same across all list pages. PHP comes with a large number of native functions, but it also provides a way to create our own.
19 steps-
Creating the Catalog Array
4:43
-
Adding Elements and Specifying a Key
3:20
-
Introducing Arrays
4 objectives
-
Associative Arrays
5:30
-
Associative Arrays
7 objectives
-
Displaying All Items
3:30
-
Multidimensional Arrays
8 questions
-
Creating the Display Function
4:56
-
Working with Functions
8 questions
-
Random Fun with Arrays
3:36
-
Introducing Functions
1 objective
-
Displaying Categories
5:50
-
Sorting Array Items
6:05
-
Item Details and Redirection
5:35
-
Array Keys
2 objectives
-
Displaying Item Details
5:55
-
More Excitement With Arrays
6 questions
-
Review Basics
3 objectives
-
Wrapping It Up
0:45
Teacher
-
Alena Holligan
After starting out in fine art and moving into graphic design, Alena found her passion for programming over 15 years ago and has never looked back. Alena enjoys community and is excited to introduce people to the wonderful world of PHP and the Portland Tech Community.
When not at her computer, Alena enjoys exploring Portland with her friends and family, including her 3 young children. She also enjoys the Symphony, Cooking, Books, Yarn and Yoga.