Viewers: in countries Watching now:
Join author David Gassner as he describes how to add dynamic data to a PHP-enabled web site in Adobe Dreamweaver. This intermediate course shows how to plan and create a MySQL database, define a PHP-enabled site in Dreamweaver, connect the site to the database, and manage and present dynamic data. David also explores Dreamweaver features such as PHP custom class introspection and site-specific code hinting as well as the differences between the CS5 and CS6 versions of the software.
This course was updated on 6/12/2012.
In data entry forms that collect personal information, it's very common to present a list of available states or other geographical regions. In a static HTML page, these sorts of lists have options that are filled in manually. For example, in this file, join3.php, there's a pulldown list, or a select control. The options in this control are listed manually. If you select the control in Dreamweaver and then go down to the Properties panel, then click the List Values button, you'll see the list of items that have been manually added to the list.
In many situations though, it's a good thing to populate these sorts of lists from a database on the server. I'll show you how to fill this sort of controlling with dynamic data from a database table. First, you'll need to make sure that your database connection is set up correctly. Go to the Databases panel, to the explorecalifornia database connection, and double-click it to open the MySQL connection dialog. The files that are included with this course have been configured for Windows and WAMP server.
The password is set to a blank string. If you're working on Mac with MAMP, type in a password of root, r-o-o-t. Then, either way, click the Test button. If you get this dialog, indicating you haven't specified a password, click OK, and click Test again. Then regardless of whether you're working on Mac or Windows, you should see the message that the connection was made successfully. Click OK, and click OK.
Open the explorecalifornia database connection, and open its Tables list, and from there, go to the states table. You'll see that the states table has two columns: stateId and stateName. These match the values that are going to be used in the pulldown list. Right-click on the table and choose View Data, and you'll see that the table is populated with all the data you need for the list. Click OK to close the panel. Click on the List Values button again and click the minus button a whole bunch of times.
You're going to remove all of the static data in the dynamic list, and then click OK. The next step will be to add a recordset to this page that retrieves the state's data from the states table on the database. Go to the Bindings panel, click the Plus button and choose Recordset (Query). Name your new recordset rsStates. Change the table to states. Leave the column is set to All.
Notice that you'll be retrieving the data for both the stateId and the stateName column. And set the Sort parameter to the stateName. Click Test and you should see the data returned in alphabetical order, by stateName. Click OK, and click OK again. Now your recordset is a part of the page. Peak at Code view, and you'll see that the code for implementing the recordset is at the top of the page, including some boilerplate PHP code, and the actual SQL statement that retrieves the data from the server.
Go back to Design View and once again click on the pulldown list which now shows that it's empty. Click Dynamic. You'll add data from the recordset. Under Options from Recordset, select rsStates. Set the values to stateId, and the labels to stateName. You can also, if you like, add a static option. The static option would be an item such as choose a state. For this example, we'll leave that blank. Click OK, save your changes, and then test the page in an external browser.
When the page opens, the data is retrieved from the server and the pulldown list is populated with the dynamic data. Let's take a look at the generated code for the select control. Close the browser, and in Dreamweaver go to Code View, and you'll see that the select control now loops over the recordset, and creates one option element for each item in the recordset. Here's the actual option element, and all the rest of this code is executing the loop over the recordset so that you get one item in the recordset for each item in the database.
So that's a look at how to retrieve data from the database server and implement a dynamic pulldown list or list control without having to do any hand coding on your own.
Find answers to the most frequently asked questions about Dreamweaver with PHP and MySQL .
Here are the FAQs that matched your search "" :
<?php include('../ZendFramework/library/Zend/Date.php'); ?
<?php echo $_SERVER['DOCUMENT_ROOT']; ?
You can then programmatically modify the include_path variable at runtime with the set_include_path() function. For example, if your physical root folder is /home/myroot, the code might look like this:
<?phpset_include_path('.' . PATH_SEPARATOR .'/home/myroot/ZendFramework/library/Zend');include('Date.php');?
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
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.