From the course: PHP for Web Designers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Controlling which rows are displayed - PHP Tutorial
From the course: PHP for Web Designers
Controlling which rows are displayed
The next stage in building the order confirmation page is to make sure that the correct image is displayed for each flower. We also need to prevent a row from being displayed if a flower hasn't been ordered, and if nothing's been ordered, we need to display a message that the customer's basket is empty. The image is, at the moment, hard coded on line 65. What we need to do is, those with a choice of color, are in the color array. And those without a choice of color, are in the image array. So we need an if else structure, to display the correct image. So let's get rid of the, name here. We still need the .JPG. But then we need to add in our PHP code block. And let's just make a few lines there, so we can see where we're working, right? Inside there, what we need is an if/else structure. So, if. And we need to check whether a particular value is set. We're going to look first in the color array. So if is set color, and then the array key will be flower name, so if that is set inside…
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
-
-
-
-
-
-
-
(Locked)
Getting form input sent by the POST method4m 48s
-
Retrieving values from a URL's query string4m 8s
-
(Locked)
Challenge: Plan the order form2m 28s
-
(Locked)
Solution: Plan the order form4m 42s
-
(Locked)
Finding and extracting a substring7m 38s
-
(Locked)
Organizing the form data into arrays7m 15s
-
(Locked)
Using a loop to build a table for the data4m 42s
-
(Locked)
Controlling which rows are displayed7m 45s
-
(Locked)
Creating a custom function to extract part of a file name7m 43s
-
(Locked)
Calculating the order total6m 34s
-
(Locked)
Using PHP sessions to preserve data3m 14s
-
(Locked)
Storing data in session variables7m 33s
-
(Locked)
Ending the PHP session and deleting the data5m 37s
-
(Locked)
-
-
-