Tutorial PHP : Adding Dynamic Data to Your Pages
Sample of the pdf document :
Creating a Recordset:
You’ll start by opening an existing page and adding a recordset to it.
1. Open index.php in the root folder of the local site you defined in the previous chapter.
Either choose File→Open and navigate to and select index.php, or double-click the file name in the
Site Files panel.
The basic structure of this page is already complete. It was built using tables, image rollovers,
Cascading Style sheets, and the other HTML features you’ve already learned. There’s nothing dynamic
about this page yet, so you’ll need to create a recordset and insert database information into the page.
2. Choose Insert→Application Objects→Recordset.
You can also click the Insert Recordset button on the Application tab of the Insert bar (see Figure 21-1
in the printed book), or click the + button on either the Bindings panel or Server Behaviors panel and
select a recordset from the menu that appears. In any case, the Recordset box should now be on the
screen. (Make sure you’re using the simple mode—you should see a button labeled Advanced.)
Next, select the information you want to retrieve.
3. Type rsProducts into the Name box.
Since Dreamweaver lets you connect to more than one database, you must now indicate which
database connection it should use.
4. From the Connections pop-up menu, select “connNationalEx.”
This is the name of the connection you created in the last chapter.
The National Exasperator database contains several tables. At this point, you’re interested in the
Products table and the Vendors table. For this page, you’ll create an index of all products for sale. That
information is in the Products table.
5. From the Tables menu, choose “products.” Click Selected.
You don’t need to retrieve all the information from the Products table. Since this dynamic page will
present a listing of all of the products, you only need basic information like the name of the product, its
price, and its inventory status. More details about each product will appear on a second page, to be
created later in this tutorial.
6. In the Columns list, Ctrl-click (⌘-click) “prodName,” “prodPrice,” and “prodInventory.”
These are the columns of data you want to get from the database.
You won’t have to filter this recordset—you can ignore these controls in the dialog box—but it would
be nice if the product names appear in alphabetical order.
7. From the first Sort pop-up menu, choose “prodName.” From the second one, choose Ascending (the
window should now look like Figure PHP Tutorial 2-1.)
The Ascending option makes certain the records start with products whose names begin with A and
end with names that begin with Z............
Click here for Download PDF / FREE
0 commentaires: