ONLINEPROOFINGSITE.COM

proofing paper white semimatte - www.onlineproofingsite.com

Menu


allow you to capture the users' input and ultimately make the search much more dynamic. Working with Variables in ASP and


PHP Up to this point, we've yet to discuss the topic variables. Variables in Dreamweaver's Recordset dialog allow you to capture user information from sessions, form requests, cookies, and application variables. Variables let you work dynamically by passing values from one page to another. If you take the search page as an example, a user submits the input in a form object to the search results page. In the search results page, a piece of functionality must be added to capture that input so that it can be automatically appended to the SQL statement's WHERE clause. In the ASP and PHP server models, that functionality is called a variable. NOTE The ASP and PHP server models support variables; the ASP.NET and ColdFusion server models support parameters. Dedicated sections to both ASP.NET and ColdFusion are outlined next.   Variables in Dreamweaver enable you to capture the data being sent from a previous page, store it, and then use it at any time in the current page. Variables contain three properties: Name: The physical name of the variable. Default Value: A default value to be assigned to the variable so that its value is never empty at run-time. Run-time Value: The value to assign the variable. You can set up a variable to capture the user's input from the search page by following these steps: 1. With the Recordset dialog still open in Advanced mode, add a variable to the variables list by selecting the Add (+) button. The variable should contain the following properties based on the server technology you are using (ASP or PHP): Server Code Name Default Value Runtime Value ASP Search abc Request.QueryString("txtSearch") PHP Search abc #txtSearch#   NOTE Notice that we entered the value abc as the default value. Because this is a required value, the text abc guarantees that at least a value is sent across at runtime. 2. To capture requests made from a form via POST in ASP, you use the Form collection of the Request object or Request.Form followed by the name of the text box name within quotes. To capture requests made from a form via GET, you use the QueryString collection of the Request object or Request.QueryString followed by the name of the parameter name which will be coming across the browser's address bar within quotes. In PHP, it's simply a matter of enclosing the name of the form object with the # symbol. 3. Modify the SQL statement as follows:   SELECT * FROM EmployeeStore WHERE ItemName LIKE '%Search%' 4. As you can see, you want to use the keyword LIKE followed by the name of the variable you just created (Search). Also, we use the % operator as a way of retrieving all the values beginning and ending with the value we're passing in as a parameter. The result of the completely formatted Recordset dialog should resemble Figure 27.6. Figure 27.6. Format the SQL statement in the Recordset dialog to accept the Search variable as a parameter. [View full size image] 5. Click OK. The recordset appears in the Bindings panel.