This is a discussion on how do i write a query in coldfusion? within the Coldfusion forums, part of the Programming Talk category; how do i write a query in coldfusion?...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
The following steps would help you to search and display the query results:
Create a Cold Fusion page with the following content: <html> <head> <title>Searching a collection</title> </head> <body> <h2>Searching a collection</h2> <form method="post" action="collection_db_results.cfm"> <p>Collection name: <input type="text" name="collname" size="30" maxLength="30"></p> <p>Enter search term(s) in the box below. You can use AND, OR, NOT, and parentheses. Surround an exact phrase with quotation marks.</p> <p><input type="text" name="criteria" size="50" maxLength="50"> </p> <p><input type="submit" value="Search"></p> </form> </body> </html> Save the file as collection_db_search_form.cfm in the myapps directory under the web_root. This file is similar to collection_search_form.cfm, except the form uses collection_db_results.cfm, which you create in the next step, as its action page. Create another Cold Fusion page with the following content: <html> <head> <title>Search Results</title> </head> <body> <cfsearch collection="#Form.collname#" name="getEmps" criteria="#Form.Criteria#" maxrows = "100"> <!--- Output the record set. ---> <cfoutput> Your search returned #getEmps.RecordCount# file(s). </cfoutput> <cfoutput query="getEmps"> <p><table> <tr><td>Title: </td><td>#Title#</td></tr> <tr><td>Score: </td><td>#Score#</td></tr> <tr><td>Key: </td><td>#Key#</td></tr> <tr><td>Summary: </td><td>#Summary#</td></tr> <tr><td>Custom 1:</td><td>#Custom1#</td></tr> <tr><td>Column list: </td><td>#ColumnList#</td></tr> </table></p> </cfoutput> </body> </html> Save the file as collection_db_results.cfm in the myapps directory under the web_root. View collection_db_search_form.cfm in the web browser and enter the name of the collection and search terms. |
|
|||
|
Writing a query in ColdFusion
By using coldfusion cfquery
Example Your_DataSourceName : DSn name we created in Coldfusion server. which refers to your database. <cfquery name="AnyName" datasource="Your_DataSourceName"> select empno,ename,sal from employee </cfquery> To display data from the above query <table> <cfoutput query="AnyName"> <tr><td> #empno# </td><td>#ename#</td><td>#sal#</td></tr> </cfoutput> </table> |
![]() |
| Thread Tools | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to find second max sal of employee with the co | chandraismoon | Oracle Tutorials | 7 | 05-16-2008 04:08 AM |
| Criticisms Of ColdFusion | encoder | Coldfusion | 0 | 05-06-2006 09:07 PM |
| comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) | Steve Summit | Tech FAQ | 0 | 06-15-2004 07:00 AM |
| comp.lang.c Answers to Frequently Asked Questions (FAQ List) | Steve Summit | Tech FAQ | 0 | 06-01-2004 07:00 AM |
| comp.lang.c Answers (Abridged) to Frequently Asked Questions (FAQ) | Steve Summit | Tech FAQ | 0 | 05-15-2004 07:00 AM |