Presentation is loading. Please wait.

Presentation is loading. Please wait.

Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.

Similar presentations


Presentation on theme: "Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy."— Presentation transcript:

1 Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy

2 Agenda Homework Homework PHP/DB PHP/DB SQL SQL myDBAdmin myDBAdmin In Class work In Class work Presentations Presentations Lab Lab

3 Using mySCC Use your desktop credentials

4 Eclipse

5 IMPORTANT NOTE All filenames lower case alphanumeric names.

6 Hosting FTP Information: FTP Information: URL:.com URL:.com Login : sccstudent Login : sccstudent Password : Maricopa Password : Maricopa Folder : Folder :

7 Database Infrastructure

8 IMPORTANT NOTE A Database Server can not have a DB with the same name. Since we use ONE DB Server, all our DBs have to have unique names.

9 Database Structure (mySQL) mySQL is a database. mySQL is a database. Databases contain objects called tables. Databases contain objects called tables. A table is a collections of related data organized in columns and rows. A table is a collections of related data organized in columns and rows. Access to information is through SQL (Structured Query Language). Access to information is through SQL (Structured Query Language).

10 Steps to interact with DB 1. Connect to server 2. Connect to DB 3. Create SQL statement 4. Execute SQL > Create record object 5. Convert record object into array 6. Close connection

11 Information needed for DB Need server name/IP (e.g. mysql..com or localhost) Need server name/IP (e.g. mysql..com or localhost) Need username Need username Need password Need password Need DB name Need DB name Need table names Need table names Need column names Need column names

12 IMPORTANT NOTE SQL Commands (SELECT, INSERT, UPDATE, etc) are almost always written in CAPS and other pieces of a SQL statement are written as normal case.

13 PHP / mySQL Syntax // Connect to server $con = mysql_connect(“SERVER",“USER",“PASSWORD"); // Connect to DB mysql_select_db(“DATABASE", $con); // Execute SQL Query $result = mysql_query("SELECT * FROM TABLE"); // Close connection mysql_close($con); http://www.w3schools.com/PHP/php_mysql_connect.asp

14 PHP / mySQL Syntax // When query has information returned // need to hold the information for display $result = mysql_query("SELECT * FROM Persons"); // The RECORDSET will be an object (e.g. $result) // Need to break the object into an array (e.g. $row) while($row = mysql_fetch_assoc($result)) { // The WHILE runs until END OF RECORD echo $row['FirstName']. " ". $row['LastName‘]." "; } http://www.w3schools.com/PHP/php_mysql_connect.asp

15 Sample SQL Statements SELECT * FROM Persons; SELECT ‘FirstName’ FROM Persons WHERE AGE>30; INSERT INTO Persons (FirstName, LastName, Age) VALUES ('Peter', 'Griffin', '35'); UPDATE PERSONS ‘FirstName’=‘Peg’ WHERE id=5; Never do a DELETE statement, instead “archive” the date. http://www.coderecipes.net/sql-statements.aspx

16 IMPORTANT NOTE The life cycle in PHP is the length of time it takes the server to find the file, process the information, and send the completed static HTML back to the client.

17 Connecting to your DB Server: mysql..com Server: mysql..com Username: sccstudent_ Username: sccstudent_ Password: Maricopa_ Password: Maricopa_ DB name: sccstudent_ DB name: sccstudent_ --------------------------------------------- --------------------------------------------- Table: week4 Table: week4 Columns: id, username, password, firstname, lastname, phone, email, created Columns: id, username, password, firstname, lastname, phone, email, created

18 phpMyAdmin

19 In class Display ALL results from DB/table Display ALL results from DB/table Web form for creating a new user id, created, username and password ONLY! Web form for creating a new user id, created, username and password ONLY! Web form for updating an existing user username and password ONLY! Web form for updating an existing user username and password ONLY!

20 Early Warning! No Class on Wednesday, November 23 (Day before Thanksgiving)

21 Questions?

22 Lab Update the web form created in class to allow the user to input first name, last name, phone, and email address. Update the web form created in class to allow the user to input first name, last name, phone, and email address. Send email to rob.loy@gmail.com with URL to input form file before 6pm on October 5. Send email to rob.loy@gmail.com with URL to input form file before 6pm on October 5.rob.loy@gmail.com

23 Homework Using the class work and lab work make the following updates… Using the class work and lab work make the following updates… Reject any creation where there are blank entries Reject any creation where there are blank entries Send email to rob.loy@gmail.com with URL to input form file before 6pm on October 5. Send email to rob.loy@gmail.com with URL to input form file before 6pm on October 5.rob.loy@gmail.com


Download ppt "Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy."

Similar presentations


Ads by Google