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, 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).<ul> <li></li> </ul> And when you preview it in the browser, you should see something like this:<ul> <li><?php echo $row_Recordset1['username']; ?></li> </ul> ![]() 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, 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.
blog comments powered by Disqus |