Join Kevin Skoglund for an in-depth discussion in this video Generate options dynamically, part of Easy PHP Projects: Measurement Conversion.
- In this movie, we will use PHP to…dynamically generate the options to…use with our HTML select tags.…In the last movie, we talked about the need to…try and find a smarter way to generate all of…the options we're going to need for the units…of volume measure.…We can do that using PHP.…What I'm thinking that we can do is…use a list of all the volume units of measure,…and then we can loop through that list…two different times, once for the from unit…and once for the to units, and each time to…that list we'll output the option tag…with the correct options that needs included.…
So let's start by going up here,…and right after the form processing,…I'm going to paste in a list of the measures.…I've got that listed as an array,…and I'm assigning that to a variable called volume_options.…You can pause the movie if you need to…copy this down, it's also the same thing we saw…on the previous slide.…So we've got cubic inches, cubic feet,…then we've got all of the imperial measures,…all of the US measures, and then cubic centimeters,…
Along the way, series designer Kevin Skoglund introduces coding strategies, refactoring techniques, and useful skills including dynamically generating form select-option values and formatting decimal numbers and scientific notation.
- Converting length and area measurements
- Using functions to avoid repetition
- Refactoring to produce simpler code
- Converting volume and mass
- Generating form select-option values dynamically
- Formatting scientific notation
- Converting speed and temperature
Skill Level Beginner
Accessing Databases with Object-Oriented PHPwith David Powers3h 47m Intermediate
1. Length and Distance
3. Volume and Capacity
4. Mass and Weight
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.