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.
Once you've defined your Dreamweaver site and associated it with your PHP server, you can start creating brand new PHP pages. For the remainder of this video series, I'll work with Dreamweaver in a new workspace named App DeveloperPlus. You can get to this work space by opening the workspace selector on the top toolbar of Dreamweaver and choosing App DeveloperPlus. You should see the following layout: CSS Styles and AP Elements at the top, Files, Assets and Snippets at the bottom on the left, and then miniature buttons that allow you to open panels like Insert, Databases, Bindings and Server Behaviors.
For this demonstration, I'll point my site definition to a new folder, I'll go to the Menu and choose Site > Manage Sites and then click Edit with the selected site, then for the local site folder I'll click the icon to browse. If you worked through the previous video, your folder will be pointed to 02_testingserver. I'll go up one folder from there and then down to 03_newphppage. I'll click Select and Save, and then click OK to close the cache notification dialog and click Done.
The Files panel in this workspace appears in the lower left corner. You should see all of the site files and the PHP-based homepage, index.php. Now the goal of this demonstration is to create a brand new PHP page from scratch. From the Menu choose File > New. In the New Document dialog choose Blank Page category and then down at the bottom choose PHP. If you're creating a page for your own site, you might want to use one of the standard layouts provided in Dreamweaver CS5.
These layouts make very good use of cascading style sheets, or CSS, to accomplish their layouts. You can choose any of these and your file will be created as a PHP file. I'm not going to use any particular layout though, because I want to keep this exercise very simple and focused. So I'll set the layout to None and click Create, then I'll go into Code view. As I've mentioned previously, a PHP page is nothing more than an HTML page. When you create a brand new PHP page from scratch in Dreamweaver, you end up with a skeleton of an HTML page.
I'm going to set the title of this page, changing it from Untitled Documents to PHP Info, then I'll save the file, selecting File > Save As, and I'll name it phpinfo.php, because I designated this as a PHP file from the beginning. If I didn't add the file extension at this point, Dreamweaver would add .php for me, I'll click Save. Now I'm going to use a very simple PHP command that outputs information about the configuration and version number of my PHP server.
I'll place the cursor after the starting body tag and press Enter a few times, and place the cursor between the body tags. then I'll go to the Insert panel, I'll click the Insert button, and in the panel I'll pull down the list of available options and choose PHP. The Insert panel will help you insert standard PHP code. I'm going to add a Code Block by clicking once, make sure you only click once, if you double-click, you'll get two copies of the code.
Then I'll click back on the page and the Insert panel will shrink back down into its original place. A PHP Code Block looks like this, its starts with a less than character and a question mark and then the phrase php in lowercase, and it ends with a question mark and a greater than character. Within the PHP code block, you can add your own PHP code. I'm going to add a function called PHP info. I'll type php and then using Dreamweaver CS5 new code hinting capabilities, I'll hold down the Ctrl key and press the Spacebar.
Dreamweaver CS5 brings up a listing of all of its known commands that start with the term PHP. I'll type IN and I'll find three items that I could add that have php and ini; I'll press the down arrow twice to move down the phpinfo. Notice that Dreamweaver CS5 gives you help automatically. This is the PHP project's own online help that's being displayed, and it'll tell you a lot about the different PHP commands that are available and how to use them.
I'll press Enter to choose phpinfo, and then type in a closing parenthesis, I'm going to call the phpinfo function without passing in any values. Now I'll save the file, selecting File > Save, and then I'll look at the page using Live View. Now before you use Live View, make sure that you can see the browser toolbar, if you can't, you can right-click on any of the toolbars and choose this item Browser Navigation. The Browser Navigation toolbar will show you what the URL is that you're browsing to within Dreamweaver, click Live View.
If you see the dialog box asking you to update the copy on the testing server, click Yes and then click Yes again for dependent files. On the right, you should see design view open up and show the resulting output to the browser. Go to the toolbar and click Design, and that will allow the Design view to take up the full available area. The phpinfo function outputs the current version number of your PHP server and all sorts of other configuration information.
One of the most important things you should know, is the location of your php.ini file, that's the PHP configuration file. I'm working on Windows with WAMP server, so my PHP file is located in my Apache 2.2.11/bin directory. If you're working with MAMP on Mac, the location will be different. Now I'll go back to Code view and see the actual output. So in this exercise, you've created your first dynamic PHP page, you've embedded dynamic PHP server-side code in the page, and at runtime, the PHP server executes the phpinfo function and outputs a bunch of very complex information to the browser.
Here's another way of executing the page through the external browser that I'll give you a little bit more information about what's going on. I'll deselect Live View, then go to the Preview button and choose my favorite browser. Once again I'll copy files to the server directory and here's the phpinfo display again. In the browser, I'll view the source. In Firefox, you can do this by selecting View > Page Source. I'll expand the size of the font so we can see it more easily, because I want to show you that that single function phpinfo actually outputs an entire web page, starting at this point with the doc type and going all the way down to almost the bottom of the page, to this ending HTML tag.
This tells me that if you're using the PHP function, you don't need the rest of the HTML structure. So I'll close the browser, go back to phpinfo.php and I'll delete everything except the PHP command. I'll save the change, run the page in the browser again, once again copying files as needed. I'll view the source and this time I only see the output of the phpinfo page.
As I'll show you in the other exercises, most of the time in your actual production pages, you'll be mixing your own custom HTML and cascading style sheets with your PHP commands to output information, but the phpinfo function is a critical tool that can help you find out what's going on, on your PHP server, which version of PHP you're running, and a lot of information about its configuration.
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.