Resources
PHP:
http://www.php.net
This is the official documentation for php, and it’s often very helpful.
http://us2.php.net/manual/en/ref.strings.php
I also recommend this one – it’s great whenever you’re working with strings.
http://www.tizag.com/phpT/
This website has some clear and helpful php tutorials.
http://us3.php.net/manual/en/language.oop5.php
This looks like a great tutorial and/or reference to classes in general and specific to php
DABL:
http://manifestwebdesign.com/developer-resources/database-abstraction-layer/
Documentation for the amazing php 5 database abstraction layer
HTML:
http://en.wikipedia.org/wiki/XHTML
http://www.w3schools.com/tags
http://www.yorku.ca/nmw/multim/html_vs_xhtml.html
http://www.htmldog.com
These are resources for html tags and their properties.
Javascript:
http://www.quirksmode.org/resources.html
Tons of great information about javascript and css
http://www.simpletutorials.com
There is an array of useful little tips here particularly dealing with javascript. (Ignore the aspects regarding useful php opensource code – it’s good, but we will use other tools to acheive that same functionality.)
General:
http://www.w3schools.com
This is a great reference for html, css, javascript, and sql
Projects
note, all projects should work in I.E. AND Firefox!
1) Hello World
- php – echo (Note – you should still have and tags in the file when it is sent back to the browser.
- Put hello world into a variable and echo it out. Use the . operator to concatenate a “
” on the end.
- phpinfo()
2) Arrays
- Create a php array and display it in a table (ex: first name, last name, address, phone)
- Make a 2-d array to create multiple such entries and display it in a table
- Use th tags to title the columns with First Name, Last Name, etc.
- Use the php “foreach” loop to display them – (you can do a function search on php.net to see how to use this.)
- Use inline css to change the look and feel of the table (or just skip this and go to 2.4a – whatever works for you)
- Now move that inline up into style tags in the head tags. Use css classes.
- Use javascript (js) to highlight a row upon mouse-over, and unhighlight when mouse-out (Hints: onMouseOver=”“, same with onMouseOut. Figure out how, in js, to switch style classes of a row.)
- Move the javascript into the head tags.
3) Classes and Objects – 1
- Create a class for a User of a training application. Include the following private properties:
- Username
- Password
- User Type (Student or Trainer)
- First Name
- Last Name
- Phone number
- Physical Address (Street, City, State, Zip, Country – feel free to make each it’s own variable)
- Male or Female
- Notes – long text field for general notes
- Use constants with integer values for each user type. Make an array of the constants. Ex. of array:
public static $UserTypes = array(
self::TYPE_STUDENT => "Student",
self::TYPE_TRAINER => "Trainer");
}
- Create public methods to retrieve or set the value of each property. Ex:
public function setUsername($value){
$this->Username=$value;
}
- Create a few instances of User objects and put them into an array
- Use foreach to output them in a table using columns for each value in 3.1 (Make Physical Address it’s own column – so combine all the variables into one table cell.)
- Try leaving some fields in some objects un-initialized. What happens?
- In the User Type cell, Use the string representation of their type rather than just an integer
4) Classes and Objects – 2
- Create child classes extending User for each User Type
- For Students, include things like Year in School, Major, etc.
- For Trainer, include things like YearsTeaching, etc.
- Display two different tables – one of students with all their attributes, and one for trainers with all their attributes.
5) Form
- Create a form to create a User. Have the appropriate html form fields for each of the User properties. Include a submit and reset button.
- Upon submitting the form, simply display a page with all the information they input.
- Create a link on the information view page that links back to the original form
- Change your submit button to an image type
- Use js to make the phone text field to only allow phone numbers chars to be typed into it (0-10.s, -’s, and ()’s ) and only numbers into the zip text field compensation type choice changes.
- Add labels to your checkboxes so people can click anywhere on the whole label and check the box
- Add a “Country” select box (drop down) and use optgroups to separate them by continents or by alphabetical letter (your preference)
- Make the “State” dropdown revert to its default (no-state-selected) value and become disabled if a country other than the United States is chosen
- Use js to show how many characters have been input into the textarea and to enforce a maximum amount of characters.
- Use tabindexes if needed to give a logical tabbing order
- Use maxlength to limit field sizes: 255 for most, 14 for phone, etc.
- Make your link back to the original form an image link. Remove any borders the anchor tag tries to add (use css).
- Validate fields with js and move all your js out into a separate file
- Put each section of the registration into a fieldset with a legend (i.e. username,password = login info; registration type, projects = work info; other stuff = personal info; etc.)
- Validate fields with php
6) DATABASE
- You should understand the following database terms:
-
- Foreign Key
- Nullable
- SQL queries
- Select
- Insert
- Update
- Delete
- Storage Engine (InnoDB, MyIsam)
- Default values
- Create a database to store the values from the User objects. Use the appropriate data types for each column.
- Populate the database with some fake users by typing them in manually (use phpMyAdmin, or software such as navicat, toad, or dreamcoder)
- Use a query editor to select Users out of your db based on a given:
- username
- lastname
- first AND last name
- first OR last name
- first AND/OR last name starts with (use LIKE)
- first AND/OR last name contains (use LIKE)
- List the username and state of users who have a State they are from (NOT NULL) in alphabetical order by that State. If there are multiple users from the same state, order them by username in reverse alphabetical order
- Create a connection with the database from php
- Use a select statement to get all users out of the database. Display them and their basic information in an html table
- Use a query editor to insert, update and delete users and their information.
- Modify your User form to create/edit rows in the database
7) DABL
- Install DABL and replace your handwritten User class and all raw sql and mysql_ functions with DABL code. See http://manifestwebdesign.com/developer-resources/database-abstraction-layer/ for a link to download and documentation.