https://MarcsComputerServices.com

PHP Class Index - If you are interested in Learning Web Development, please email Marc@MarcsComputerServices.com

1) Create an HTML, Hypertext Markup Language, page with an If Else Statement.  An example is given with the file, IfElse.php.  Comments start with slashes infront of them.  Remove the slashes from and add them to another line from line 5 to line 7.  Then, you can run the program  again to see different answers.

 

 

 

2) Create an HTML page with a While Loop. An example is given with the file, WhileLoop.php.  If the condition in the while statement is true, the following statements below it are executed.  In this case, they are run 10 times.

 

 

3) In PHP, MySQL databases can be used to save data to tables.  First create the table.  PhpMyAdmin can be used to create the tables in a database.  It comes with the installation of MySQL.  An example is shown with the image, SampleDatabase.jpg. This table is used with my Item Listing program on http://localhost:81/wordpress/items/ItemListing.php   I'm running WordPress on my Windows 10 Laptop.  This program is also on my website, https://marcscomputerservices.com  Please let me know if you would like to run my ItemListing.php app or my Appointment Calendar App on https://marcscomputerservices.com/app/Logon.php

 

 

 

4) To show what is possible, I included an example of inserting records into a table from a web page called Insert.php. Along with HTML, the program includes JavaScript and a Form within a Table.  It also has the MySQL statements to add the record to the table.  JavaScript is used to check  the user input to see if it is valid.  Usually, before a record is added to a table, you need to see if it is already in the table.  If it is not, it can be added without creating a duplicate record.    

 

 

 

5) Even calculus problems can be solved with PHP.  My example shows how to find the area under a curve y = x squared from 2 to 5.  It can be calculated using calculus.  Assignment one is to rewrite the C++ code as a PHP program.  The C++ program is called rect.c, and the Assignment one is found in PHPAssignment1.rtf.

 

 

 

6) File processing: A program called SaveToFile.php reads an address table and writes it to a file called mlist.txt.  Sometimes clients want to have a backup of their tables.  This is a good way to create a backup file since it can be imported into a MySQL table using the phpMyAdmin app.

 

 

 

7) File processing: After a file is created from a MySQL table, it can be used to recreate the same table.  ReadFromFile.php reads records from an address table and writes the data to your computer.  If you compare the file data to the address table, you can see they are the same.

 

 

 

8) Using a table: random.php shows how a table can be used. It is initialized with one hundred random numbers. Then, the numbers are sorted using a Bubble Sort. The unsorted table is displayed before and after it is sorted. Random.rtf explains the program.

 

 

 

9) PHP Assignment 2 is described next. Your assigment is to rewrite the filter3.c program in PHP. Filter.c and Filter3.c are included in the zip file for the assignment. Solution for the PHP program is filter2.php The output is placed in another file called filterout.txt It should not have any comments starting with a double slash like "//".

 

 

 

10) PHP Assignment 3: Create a Report/Listing with two tables, tbl_isaac and tbl_customer. They are shown in screen prints that were saved as jpeg files, tbl_isaac.jpg and tbl_customer.jpg You can see the table structure from the jpg files. After the tables are created in MySQL using PHPMyAdmin, add some records to each table. While browsing each table, click on the insert tab. Then, add a few records. The Id field should be from 1 to 3, and the c_id should be alo from 1 to 3. In the tbl_isaac, make sure that the c_id field corresponds to the c_id field in the tbl_customer's c_id field. Now, a Customer Item Report can be created by referencing the ItemCustomerReport.rtf file and using the ReadFromFile.php table listing. A while and echo statements are used to display the address table. Copy the statements and insert your variables to show the item customer report.