From the course: PHP for Web Designers
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Using a loop to build a table for the data - PHP Tutorial
From the course: PHP for Web Designers
Using a loop to build a table for the data
The next stage in processing the data submitted from the Build a bouquet page in the Hansel and Petal site, is to use a for each loop, to display a table row for each type of flower that's been selected. Only two rows are going to be needed in the table at this stage. One for the table headers, and one to go inside the loop to display the order. So let's scroll down and find the table. There it is. It begins there on line 55. The first table row contains the headers, and then there is another table row, and we'd need to get rid of all the remaining table rows. So just scroll down, select them all, and find the end of the table. There it is. And we just, delete that. And we've got, just one row left in the table apart from the, header row. So this is going to be wrapped in a for each loop. And the only array that we've got that contains a value for each flower, is the quantity array. So I'll use the quantity array, for our loop. So let's add a php block here, before the second table…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
Getting form input sent by the POST method4m 48s
-
Retrieving values from a URL's query string4m 8s
-
Challenge: Plan the order form2m 28s
-
Solution: Plan the order form4m 42s
-
Finding and extracting a substring7m 38s
-
Organizing the form data into arrays7m 15s
-
Using a loop to build a table for the data4m 42s
-
Controlling which rows are displayed7m 45s
-
Creating a custom function to extract part of a file name7m 43s
-
Calculating the order total6m 34s
-
Using PHP sessions to preserve data3m 14s
-
Storing data in session variables7m 33s
-
Ending the PHP session and deleting the data5m 37s
-
-
-
-