New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Getting data from a database: Part one

From: Dynamic Dreamweaver Websites: Creating Login Areas

Video: Getting data from a database: Part one

We are now going to take a look at how to pull data from a database and populate our webpages with that data. Make sure that within XAMPP or MAMP your web server specifically and your database are turned on. We also need to make sure you have a connection setup to the database so you are able to view your database data from within Dream Weaver. If you do not have a connections folder. With comelogin.php inside of it.

Getting data from a database: Part one

We are now going to take a look at how to pull data from a database and populate our webpages with that data. Make sure that within XAMPP or MAMP your web server specifically and your database are turned on. We also need to make sure you have a connection setup to the database so you are able to view your database data from within Dream Weaver. If you do not have a connections folder. With comelogin.php inside of it.

You will want to go out and make sure you've done a complete setup for this course and created that data base connection file. We're going to create a new PHP page and I will save this. We'll do a save as Add data. So it's a brand new PHP page called Add data and what we want to do is get some of our database data on to our page over here.

Now within our database we have a table called Tours, and I know you are not familiar with the database at this point. So lets take a look at the Tours table. In order to do that I can right-click the table name and go down to View data. And this is a listing of all of the various tourists that Scuba to you arranges for clients. So there are quite a few tourists available here. Here's the Tour name, a description of the Tour. Here we are the number of days of the Tour, the number of diving days within that Tour, costs, whether meals are included or not. And also, if it's a Liveaboard or not.

And we're storing the data for Liveaboard as true false values. Either true it's a Liveaboard, or false it's not. And that was done when the database was created. We're not going to be concerned about that piece right now. What we want is to get a nice listing of all of our Tours onto our web page. So, how we go about doing that? We have 25 Tours listed within this interface at any given time. So here is our 25 Tours.

I can see the remainder of the Tours if I click next. So there is a total of 27 Tours our company offers. It's good to know that number to make sure that you double-check once you pull the data onto the page and make sure it does match the actual data in your database. So there were 27 Tours, so I'm going to type Tours. I'm going to use Ctrl+1 or Cmd+1, in order to make that a header, just so it's easier to see the page. And then hit Enter or Return.

So I can put my cursor anywhere in this first line. And hit Ctrl or Cmd+1. That's makes it a header one and then just hit Return or Enter. This is where we're going to list our Tours on the page. How do we pull data out of a database, well we need to go over, not to the databases tab, because all that does is show us the information in the database. It does not allow us to pull it out. What we want is the bindings tabs right next door to that.

If for some reason your binding tabs is not showing, you can always access it by going to Window Bindings. Also you want to make sure that all three are checked. In case they are not within this area, you will want to go back to the data bases tab and make sure you can get your tables properly set up. I would suggest you go back through the installing course files and also setting up the database to make sure that Dreamweaver understands the databases and sets up a connections folder for you.

Now within the Bindings tab, I'm going to hit the Plus sign, and I'm going to choose Record Set. Now within this Record Set area, we need to give our query a name, so I'm going to put the letter Q, meaning it's a query, and use the word Tours, because that's the information we are pulling out of the database. We only have one connection to find. This is that connection that's being stored in our connections folder. Once we make the connections to the database, we have access to all of the tables within the database.

So I'm going to choose the Tours table. Now, at this point, you may be in an advanced interface, a slightly different looking Record set area. So, let me show you going back and forth at this point, if I click this advanced button, I move into a different looking Record Set builder, and this is known as the Advanced view. But what I like about this view, even if you're not doing a table join, and I'll mention that in a minute.

Even if you're not doing that It gives you a chance to easily see the sequel that Dreamweaver is creating for you. Now this is a very simple sequel statement. A select statement postdata out of the database. You can build your record set in the simple interface. If I click this button, it takes me back to that interface or I could also build my select statement down in this area. I'm not going to cover doing it this way.

At this point, this is a simple sequel statement. So I'm going to click the simple button. I think when you're just starting out it's much easier to use this interface, as long as it's only one table you're compiling data from this interface is much easier. Now we have to decide what data we want pull out of the database. And what I'm going to do is click on selected. If I'm in all, everything's great out. The assumption is you want to pull all of the data out of the database. We don't need all of it, we just want to limit it to exactly what we want. So, I will pull out just Tour name.

I'm not going to filter in anyway. So I won't talk about this piece but I am going to sort. I want the data base to return this information based on Tour name, alphabetical order, beginning with A. So if I click the test button. Here is the information that's returned. Nice and neatly returned in alphabetical order. So I'll click okay. It's a good idea to test your queries.

As soon as a I click okay, I now have access to that record set from within the Bindings panel. And right after the word record set is Q Tours. That's the name of my Tour. In order to work with this I can drag it out onto the page from this panel. So I now have my Tours populating the page. Now if I click the Live View button or if you do not have the Live View button in your version of Dreamweaver. Click on this and preview in the full browser.

I'll click on live view and you can see, I definitely have a single Tour put onto the page, not 27. So we will need to add something in order to get all of the Tours printed onto our page. And we'll need to take a look at how to do that. We're going to let Dreamweaver help us through that process.

Show transcript

This video is part of

Image for Dynamic Dreamweaver Websites: Creating Login Areas
Dynamic Dreamweaver Websites: Creating Login Areas

43 video lessons · 1556 viewers

Candyce Mairs
Author

 
Expand all | Collapse all
  1. 1m 32s
    1. Welcome
      1m 32s
  2. 2m 57s
    1. Course overview
      1m 16s
    2. The course environment
      1m 41s
  3. 26m 58s
    1. Static vs. dynamic requests
      4m 8s
    2. Installing XAMPP on a Windows system
      8m 54s
    3. Installing MAMP on a Mac system
      4m 29s
    4. Using admin consoles
      3m 54s
    5. Installing the course files
      5m 33s
  4. 18m 36s
    1. Overview of the Dreamweaver interface
      6m 22s
    2. Setting up the course site
      6m 20s
    3. Previewing pages
      5m 54s
  5. 33m 38s
    1. Creating PHP pages
      5m 45s
    2. Adding PHP code
      5m 44s
    3. Displaying variables
      4m 45s
    4. Commenting your code
      5m 30s
    5. Working with includes
      5m 58s
    6. Building the course templates
      5m 56s
  6. 35m 13s
    1. What is a database?
      5m 2s
    2. Adding database tables
      7m 34s
    3. Connecting to the database
      8m 28s
    4. Getting data from a database: Part one
      8m 25s
    5. Getting data from a database: Part two
      5m 44s
  7. 1h 16m
    1. Planning the login process
      7m 25s
    2. Creating a login form
      7m 45s
    3. Adding form validation: Part one
      9m 22s
    4. Adding form validation: Part two
      1m 37s
    5. Exploring the registration page
      7m 17s
    6. Correcting table fields
      6m 1s
    7. Setting up the login landing page
      4m 1s
    8. Using server behaviors
      3m 36s
    9. Inserting new members
      8m 48s
    10. User authentication
      10m 3s
    11. Restricting access to pages
      5m 17s
    12. Testing the login
      4m 53s
  8. 1h 6m
    1. Admin area overview
      5m 9s
    2. Adding new users
      5m 19s
    3. Restricting access
      12m 25s
    4. Planning the admin update area
      5m 19s
    5. Building the members table listing
      6m 55s
    6. Building the querystring
      9m 14s
    7. Populating the update form
      6m 33s
    8. Updating the database data
      11m 28s
    9. Testing the admin update process
      3m 47s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold

Are you sure you want to delete this note?

No

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.