$24.99
Lab 7: Building a Database-enabled Web Site using PHP
Please follow the setup instructions located in the assign/setup directory.
The sample code for these examples is code/304_lab7_starter_php.zip.
Example 1
Here is the code to show "Hello World!" using PHP:
```
```
Click for a demonstration of the Hello World code
The URL of the PHP file is: http://localhost/HelloWorld.php
Modify the code using a text editor. Try and change the code so that the output looks like this:
Hello World Again!
1
2
3
4
5
Click here for a demonstration of the Hello World Again code
Solution - HelloWorldAgain.php
Example 2
Example code to query the workson database and return some answers in a table. To query the COSC 304 database, the url is host = cosc304_mysql, database = workson and put in your user id and password. There is also sample code for SQL Server.
Example 3
Modify the sample PHP code for querying WorksOn such that for each department you list its projects and then its employees. The output should look like this (click here).
Solution - WorksOnDeptEmpProj.php
Example 4
You can pass and receive parameters between PHP pages. An example is to create an HTML form that collects user input and then passes this information to a PHP file to perform the query and return the answers.
Query Form Example
PHP Code for Performing Query
Example 5
Create your own query form for the WorksOn database. Your form should have boxes for the Employee name and Project name that accept partial matches (using LIKE '%queryString%'). The PHP file should receive the parameters and create a query that lists all WorksOn records where the employee name and project name are as specified. Show the count of the # of records at the bottom of the page. An example query form and system is available.
Solution - HTML File
Solution - EmpProjQuery.php
Lab 7 Assignment