Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Once you've defined a recordset in a PHP page, you can then display the data in a number of ways. For this demonstration, I'll use a file named tours.php. This file already has a recordset defined. If you look at the file in Code View, you'll see all the PHP code for lines 1 through 39. You can also go to the Bindings panel and find the recordset there, and double-click it open it. This is a simple recordset, so it's best viewed in that version of the recordset builder.
If you want to make any changes to the recordset, you can do so either from here or by manually modifying the SQL code in the PHP page. Now I'm going to preview the page in an external browser, and I'll show you that right now we're not actually using the data in the page. The page has all static HTML, including one detailed instance of a tour package, named Backpac cal. I'll go back to the page in Dreamweaver and look at the page in Design View.
I'll scroll down to that section, I'll select the title in the package, and then go back to Code View and show you that all the information about this tour is hard-coded. We want to replace this information with repeating data from the packages recordset. Here's how I'll do it. I'll go back to Design View, and I'll start with the title element. I'll select that value, and then I'll go to the Bindings panel. I'll open the recordset, and Dreamweaver shows me the three columns that are being returned in the recordset.
I'll click on the packageTitle, and I'll drag it into the place, dropping it on top of this selected static text. That replaces the static text with some PHP code that outputs the packageTitle. With that text selected, I'll go back to Code View and show you that the PHP output looks like this: php echo, then the name of the recordset, and then the name of the column as a string.
I'll do the same thing for the package description. I'll go to Design View, I'll select the text for the package description, I'll go to the Bindings panel, and drag the packageDescription column on top of the selected text. Then I'll go back to Code View and show you the exact same sort of code here. You can do the same thing in Code View. For example, the image source is currently set to a hard-coded image file name, but we have that information also in the recordset.
I'll select the name of the file, but not the location in which the file is stored. Then I'll go to the Bindings panel, and I'll drag the packageGraphic column on top of the selected text. That replaces the hard-coded graphic file name with the dynamic file name from the recordset. I'll do something very similar in the alt value for the current image. That's also set to the title of the package, so I'll select it, I'll go to the Bindings panel and drag in the packageTitle on top of the selected text.
Now let's take a look at all of the generated code. The tour description is using four dynamic values, the packageTitle used twice, both in the heading 2 and in the alt value for the image. Then the actual name of the image is being drawn from the database here, and the description is being drawn from the database right here. I'll save the changes, and then I'll look at the page in Live View. I'll update the copy of the file on the testing server when prompted, then look at Design View, and I'll see the result.
The output looks exactly the same as it did before, but now it's dynamic. The data is being drawn from the database at runtime. Right now, I'm only displaying one record. I'm going to change this now to repeating records, so that I see one instance of this package information for each row in the recordset. I'll exit Live View, and then in Design View, I'll locate the package information. I'll click anywhere inside the package information, and then in the tag selector, I'll choose tourDescription, the div tag that wraps all that information.
Now, I'd like to make that div tag repeat, once for each row. I can do that either from the menu or from the Insert panel. I've been using the Insert panel a lot, so this time I'll go through the menu. I'll choose Insert > Data Objects > Repeat Region. I'll choose the only recordset in this file, rsPackages, and I'll choose All records, rather than 10 records at a Time, and click OK. That div tag is now displayed with a visual aid showing the word "Repeat." That means that we're repeating the div tag once for each row in the selected recordset.
I'll look at the page in Live View again. If prompted, I'll say yes, I want to save my changes, and then I'll update the file on the testing server, scroll down, and show you that now I'm displaying all the data for the selected table. There are nine rows in this selected table, and therefore nine instances of the selected div tag in the repeating region. So that's how you can dynamically output data from a recordset, using the Dreamweaver repeating region architecture.
You replace the literal values in your HTML with dynamic values from your recordset and then define the entire div tag containing the data as a repeating region, and the HTML is generated at runtime by PHP and MySQL.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 73647 Viewers
80 Video lessons · 129303 Viewers
52 Video lessons · 63673 Viewers
59 Video lessons · 49431 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.