Home arrow PHP arrow Page 6 - Building PHP Applications With Macromedia Dreamweaver MX

Bringing In The Database - PHP

Looking for a RAD tool to help you quickly and efficiently develop PHP-based Web applications? Or just new to PHP and MySQL in general? You might want to spend some time with Dreamweaver MX, Macromedia's latest revision of their venerable HTML editor, which comes with some nifty new ideas designed to minimize hand-coding of PHP scripts.

  1. Building PHP Applications With Macromedia Dreamweaver MX
  2. Hooking Up
  3. Test Drive
  4. Breaking Ground
  5. Naming Names
  6. Bringing In The Database
  7. Appearances Are Everything
  8. In And Out
  9. I, Robot
  10. Weaving The Web
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 32
December 18, 2002

print this article


One of the coolest features of Dreamweaver MX is the ability to build a dynamic database-driven Web site without having to write a single line of PHP code on your own. Over the next few pages I'm going to demonstrate how, by having Dreamweaver do the hard work of writing PHP code that allows you to view, add and delete records from a MySQL table.

Let's assume that I have a database table called "user", as shown below.
mysql> SELECT * FROM user;
| id | username 
| password         |
|  3 | merrill  | 2fda14e52bde1a87 
|  4 | pooja    | 0d53926314545f3c |
|  5 | john     | 2ca0ede551581d29 |
6 | joe      | 7b57f28428847751 |
|  7 | tom      | 675bd1463e544441 |
|  8 | 
bill     | 656d52cb5d0c13cb |
6 rows in set 
(0.05 sec)
Now, the built-in features of Dreamweaver MX allow you to automate the processes of listing the records in the table, adding new records, modifying existing records, and deleting records - all with minimum hand coding.

The first thing to be handled is the database connection. Dreamweaver MX does the dirty work of opening, managing and closing the database connection - all you need to do is pop open the "Application" panel (on the right side of the workspace), click the "Database" tab, hit the button with a plus (+) symbol on it, and select "MySQL Connection" from the option list.

You should see the following dialog:

This box allows you to specify access information for the database server. For this example, create a connection called "dbConnect" and provide Dreamweaver with the username and password required to access the database server, together with the name of the database to be used.

Once the connection has been created, Dreamweaver will automatically add a set of scripts to your site directory; these will be used for all subsequent database interaction. If the connection is created successfully, you should be able to view all the tables (as well as views and stored procedures for compliant databases) in the "Database" tab of the "Application" panel.

With the database connection created, the next step is to write a script that will list all the records in the table. Use the "Bindings" tab of the "Application" panel to create a "Recordset" object (click the button with the plus symbol again to get to this option) and you'll get a simple wizard-like interface which allows you to retrieve a set of records from the database.

Once you've filled in the requisite information - note that you can also sort and filter the results - hit the "Test" button to see if everything works as it should. If it does, save your settings and you'll now see a new item in the "Binding" tab of the "Application" panel, referencing your newly created Recordset.

You can customize the SQL query created via the "Advanced..." button in this wizard.

>>> More PHP Articles          >>> More By Harish Kamath, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: