HomePHP Page 7 - Building PHP Applications With Macromedia Dreamweaver MX
Appearances Are Everything - 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.
Now, go back to the editor and decide how you want to display the data returned in the Recordset. I like to keep things simple, so I merely created a bulleted list of users,
<ul>
<li></li>
</ul>
and then dragged columns from the Recordset object in the "Application" panel
to the appropriate place on the page where I'd like the data displayed (Dreamweaver wrote the code for me).
And when you preview it in the browser, you should see something like this:
Cool, huh? I managed all that using simple point-and-click actions, with no requirement to know anything about PHP's MySQL API or remember complex function syntax.
Of course, the example's still somewhat incomplete - all it does is display the first record. What we really need is the entire recordset returned by the SQL query. In order to meet this and other requirements, Dreamweaver includes a variety of different "server behaviors", which can be used to add extra functionality to your application.
In order to see how this works, select the first item of your newly-created list in the editor,
pop open the "Server Behavior" tab of the "Application" panel, and select the "Repeat Region" behavior from the drop-down option list, and tell it to loop for as many times as there are records.
Dreamweaver will automatically insert PHP code that iterates over the returned Recordset object and print the entire set of records returned. Here's the code,
<ul>
<?php do { ?>
<li><?php echo $row_Recordset1['username'];
?></li>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
?>
</ul>
and here's the output:
Dreamweaver comes with a whole bunch of other, similar behaviors to meet most common requirements - you can just as easily (for example) display the total number of records found, implement paging with next and previous links, or dynamically show sections of a page based on the current position of the recordset pointer.