Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
At this point, in our add data page, we have created a record set. If you need to view that record, set, or modify it in any way you can, double-click the word record set and it pops up the record set interface once again. So I could make changes here if I needed to. When I click OK, those changes would take effect. So, here is our record set information. The only thing I pulled out was Tour name.
Now, we have a bit of an issue at this point. If I preview this in the browser, I'm only getting one Tour. There is nothing wrong with what we have done so far and I should probably make this look proper by plugging in to our listing, in our title. Looks pretty tacky, just having Untitled Document in the browser. So I'll save that. Now, how do we get all of the tours to be populated onto the page? So let's take a look at Code View and see what Dreamweaver created for us. There's quite a bit of information inside of this area that Dreamweaver did for us. The first thing is Dreamweaver pulled in our connection information, so PHP understands how to connect to the database.
The next piece is a bunch of information in order to pull the Tour information out of the database. But the piece that is printing the information to the page, using the Echo command is on line 53 here, and the way a page is read is left to right, top to bottom. So when this page is being read, it comes down, hits line 53, PHP comes in and processes this information, pulls out the first item in our tour, and ends the page.
So, PHP is doing exactly what we have told it to do. What we need to do now is tell PHP, okay, keep printing to the page for every item within this query, and how do we do that? Well, it sounds like it will be complicated, but Dreamweaver makes this so simple using something called a server behavior. I will go back to Design View. Within Design View, I'm going to select that recordset information for Tour name, and I'm going to go over to the server behaviors panel. Now you can see, we have a couple of items in here that Dreamweaver has done for us already.
One is pulled the recordset which we did in the Bindings area. Then when we dragged that Binding to the page, this was created automatically. What I'm going to do is add one more. A server behavior is a snippet of code that Dreamweaver drops onto your page in order to accomplish a task. So, what we want is to tell PHP, repeat this region over, and over, and over for every Tour in the database. So I click Repeat Region.
Dreamweaver wants to know how many Tours we want to show at a time. I'm going to show all of them, there are 27. I could specify only a certain number at a time. But if I do that, then we need to wait for the user to move around the different pages in order to see the different Tours. So I'm just going to do all records for now. Dreamweaver has a way to work with showing only certain records at a time. I will click OK. You can see we get this little Repeat tab here, and Repeat Region has now been added.
I will save my page. And if I go out into Live View, now, you can see I have all of my Tours on the page. You do need to turn Live View on and off manually. I'll go out into the browser and there are my Tours. Now, there is a paragraph in between these. If we look at the code itself in Code View, you will see, there is a paragraph surrounding all of this. If I did not want it to be in a paragraph, I could eliminate the paragraph tags and put them directly under one another. So I'm going to do that.
So I'm going to delete the opening paragraph. I will delete a closing paragraph, and what I'm going to put instead is a break, an XHTML compliant break. Save the page. Now, if I go out and preview this in the browser, they're listed one after the other. You can see, Dreamweaver makes it really easy to work with database data using the server behaviors piece and the Recordset builder.
So we did not have to write any code in order to pull data out of the database, and populate it onto the page using a looping statement. So that the query continues to run, that code continues to run printing out everything within our query for us. So there is a listing of all of the Tours that Scuba (UNKNOWN) offers for clients.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 105121 Viewers
56 Video lessons · 116895 Viewers
71 Video lessons · 86111 Viewers
131 Video lessons · 41178 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.