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

Extending the WordPress database

From: Dreamweaver and WordPress: Building Sites

Video: Extending the WordPress database

All of the posts, pages, settings and even user details for a WordPress- driven site are stored in a MySQL database, established when you first install WordPress. For the most part, this is a seamless invisible operation, so much so you may forget that you've got a fully functioning database at your disposal. In this chapter, we'll take a look at one of the ways you can leverage that database and Dreamweaver's code- writing prowess to include dynamic data from your own database tables in your WordPress pages.

Extending the WordPress database

All of the posts, pages, settings and even user details for a WordPress- driven site are stored in a MySQL database, established when you first install WordPress. For the most part, this is a seamless invisible operation, so much so you may forget that you've got a fully functioning database at your disposal. In this chapter, we'll take a look at one of the ways you can leverage that database and Dreamweaver's code- writing prowess to include dynamic data from your own database tables in your WordPress pages.

Let's start with creating a new table in the WordPress-created database. So, I am going to switch over to phpMyAdmin, which I've invoked from WAMP server, and I'll choose my database, tpa, and then select SQL. Now I can paste in any SQL here that I want. I had previously developed a SQL table and then exported that file. It's now stored as planets.sql, located in the Exercise Files, under Chapter 5, 05_01.

So let's go into Dreamweaver and pick that up. Now you could import it, but I want to show you the code first before we bring it in. There is the code. When you're moving from one database to another it's always better to copy the code and paste it into your SQL field rather than inserting an entire file, because quite often the database names that you see here on line 19 are different. In this case, they're the same, but I've stumbled on that block many a time.

So I am going to select everything, doing a Ctrl+A, Command+A on the Mac, and then copy it, and now let's head back to phpMyAdmin and do a Ctrl+V or Command+V to paste it in. Now I am going to scroll back up to the top. And just as a reminder, this is the value that you want to double-check. You'll see up here it will say "Run SQL query/queries on database" and then the name of the database. And if it's not the same, you'll need to change this value where it says database tpa.

I think we're good. Let's go ahead and click Go. It's in the lower right here. After you've clicked Go, click on Structure and you'll see planets listed there as the new table. You can also go over to the little refresh here and reload your navigation frame and you'll see planets there. With the data in a new database, we're ready to create a new database connection in Dreamweaver. So back to Dreamweaver. I'll close my planets.sql file. Now I'll need to drop out of Live view in order to access the proper panel.

So I'll toggle Live View off and then go to Window > Databases, and once I have that, I'll click on adding a new connection. Select MySQL Connection and then I am going to give it a name of connTPA, because we can use this connection to access all the tables that we'll need for the site, not just the single one we inserted. In the MySQL server field, enter the name of your server-- in our case, it's localhost--and then the user name, which is root. You'll call that there was no MySQL password set up. And now let's choose our database.

There is tpa. Click on OK. You can go ahead and click Test if you like. Dreamweaver will pick up on the fact that we haven't specified a password. In this case it's okay because we are not a production environment at the moment. And I'll click OK. And there is our new connTPA. And if I expand that and then expand Tables, we'll see our planets table, along with all of the other WordPress tables. Now also, if I expand my Files panel and scroll up to the top, you'll see the Connections folder that we have here.

This is the standard way the Dreamweaver works with connections. It puts a folder in the site root. There are a couple of ways that we can use this connection in our WordPress template pages, but the standard technique isn't one of them. The quickest way I've found is to simply copy the connections folder, with the PHP file that was created within it, to our theme folder. So I am going to right-click on Connections, choose Edit > Copy, and then go down to our theme folder and right-click again, Edit > Paste.

Of course, you can use the keyboard shortcuts if you want. You should see down at the bottom there for the moment, the Connections folder. If I expand it, there is our connTPA.php file. Dreamweaver has just refreshed, so it's put it back up at the top. Now that the Connections folder has been transferred, you're ready to create a recordset and apply it to a WordPress template file. I'll show you how in this chapter's video "Including a recordset."

Show transcript

This video is part of

Image for Dreamweaver and WordPress: Building Sites
Dreamweaver and WordPress: Building Sites

21 video lessons · 16497 viewers

Joseph Lowery
Author

 

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
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Dreamweaver and WordPress: Building Sites.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

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.