Presentation is loading. Please wait.

Presentation is loading. Please wait.

PHP and SQL Server: Queries IST2101. Three-Tier Architecture Three-tier architecture means that the Web server and the DBMS are on separate servers IST2102.

Similar presentations


Presentation on theme: "PHP and SQL Server: Queries IST2101. Three-Tier Architecture Three-tier architecture means that the Web server and the DBMS are on separate servers IST2102."— Presentation transcript:

1 PHP and SQL Server: Queries IST2101

2 Three-Tier Architecture Three-tier architecture means that the Web server and the DBMS are on separate servers IST2102 Client (PC) Web Server DBMS PHP is run on the web server Browser Microsoft SQL Management Studio Our technical setting

3 What we have learned PHP and SQL connection in last class – http://my.up.ist.psu.edu/zuz22/query.php http://my.up.ist.psu.edu/zuz22/query.php IST2103

4 Today’s Objectives Answer different queries from PHP Cases: – http://my.up.ist.psu.edu/zuz22/case1.php http://my.up.ist.psu.edu/zuz22/case1.php Review exercise – http://my.up.ist.psu.edu/zuz22/case2.php http://my.up.ist.psu.edu/zuz22/case2.php – http://my.up.ist.psu.edu/zuz22/case2a.php http://my.up.ist.psu.edu/zuz22/case2a.php – http://my.up.ist.psu.edu/zuz22/case3.php http://my.up.ist.psu.edu/zuz22/case3.php – http://my.up.ist.psu.edu/zuz22/case3a.php http://my.up.ist.psu.edu/zuz22/case3a.php Lab exercise IST2104

5 Prepare Database We will use the database in Chapter 3 IST2105

6 Prepare Database Log into your SQL Server application and check whether you already have these 4 tables If not, do the following… – Delete any tables (assignment, project, employee, and department) you have in your database Right click table, click “delete” Because of the referential integrity constraints, you need to follow certain order to delete the tables: assignment  project  employee  department – Create new database Download SQL-Create-Tables.sql from SQL (Ch. 3) class on course website and run it – Insert data Download SQL-Insert-Data.sql from SQL (Ch. 3) class on course website and run it IST2106

7 Prepare Database (cont.) You should now have the 4 tables in your database – If not, right click Tables, and click “refresh” Check whether you already have the data in your tables – Right click on a table and click “Select Top 1000 Rows” IST2107

8 Case 1. Browse a Table (Review) http://my.up.ist.psu.edu/zuz22/case1.php IST2108

9 Case 1. Get it run on your webspace (Step 1) Download week11-3-cases.zip from wikipage. Unzip it, you will have 8 PHP files. Copy all the files to your webspace. IST2109

10 Case 1. Get it run on your webspace (Step 2) Open process_case1.php from NotePad++ and modify the information IST21010 Input your own information

11 Case 1. Debugging Visit your php page and query your database – http://my.up.ist.psu.edu/YourPSUID/case1.php http://my.up.ist.psu.edu/YourPSUID/case1.php What problems do you see? How to fix them? IST21011

12 Case 2. Browse a Table with Constraint http://my.up.ist.psu.edu/zuz22/case2.php IST21012

13 Case 2. Get it run on your webspace Follow the steps as Case 1 Open process_case2.php and add your database information to the file Visit your PHP page from Internet: http://my.up.ist.psu.edu/YourPSUID/case2.php IST21013

14 Case 2. Code Specification IST21014 case2.php

15 Case 2. Code Specification (cont.) IST21015 case2.php process_case2.php

16 Any Problem with Case 2? Is there anything we can improve in terms of its utility and appearance?

17 Case 2a. Browse a Table with Constraint – Values from Database http://my.up.ist.psu.edu/zuz22/case2a.php IST21017

18 Case 2a. Get it run on your webspace Follow the steps as Case 1 Open case2a.php and process_case2a.php and add your database information to both files Visit your PHP page from Internet: http://my.up.ist.psu.edu/YourPSUID/case2a.php IST21018

19 Case 2a. Code Specification IST21019 case2a.php

20 Case 2a. Code Specification IST21020 process_case2a.php Same as process_case2.php except “Go back” action

21 Compare Case 2 and Case 2a IST21021 Case 2: manually code all the submit buttons Case 2a: dynamically generate all the submit buttons

22 Case 3. Browse a Table with Constraint (Dropdown List) http://my.up.ist.psu.edu/zuz22/case3.php IST21022

23 Case 3. Get it run on your webspace Follow the steps as Case 1 Open process_case3.php and add your database information to the file Visit your PHP page from Internet: http://my.up.ist.psu.edu/YourPSUID/case3.php IST21023

24 Case 3. Code Specification IST21024 case3.php Compare with case2.php

25 Case 3. Code Specification IST21025 process_case3.php Same as process_case2.php except “Go back” action

26 Case 3a. Lab Exercise Now we want to merge the improvements we made in Case 2a (values retrieved from database) and Case 3 (using dropdown list) to create a better webpage. http://my.up.ist.psu.edu/zuz22/case3a.php IST21026

27 Case 3a. Lab Exercise Hint 1 Create case3a.php in your webspace, copy from case2a.php and modify it IST21027 Action to which PHP page?

28 Case 3a. Lab Exercise Hint 2 Modify your case3a.php IST21028 How to modify this segment to echo something like a dropdown list? Case2a.php will generate this

29 Case 3a. Lab Exercise Hint 3 Create process_case3a.php, copy from process_case2a.php and modify it IST21029 This is the only place you need to modify


Download ppt "PHP and SQL Server: Queries IST2101. Three-Tier Architecture Three-tier architecture means that the Web server and the DBMS are on separate servers IST2102."

Similar presentations


Ads by Google