ColdFusion is a simple language to learn and use primarily because it employs a tag-based syntax, which makes the transition between HTML (the language that your Web browser uses to render content) and CFML (ColdFusion Markup Language, the language that ColdFusion uses to generate that content from dynamic data) within your code very natural. Take, for example, the following HTML listing of companies (no CFML is in this code):
<table>
<tr>
<td>13</td>
<td>The Very Big Corporation of America</td>
</tr>
<tr>
<td>14</td>
<td>Ma's Homemade Pies</td>
</tr>
<tr>
<td>15</td>
<td>Shecky Records</td>
</tr>
</table>
By using ColdFusion's tag-based syntax, you can easily generate this table dynamically from data stored in your database (the CFML is boldfaced in the following example), as follows:
<cfquery name="GetCompanies" datasource="MyDatabase">
SELECT CompanyID, CompanyName
FROM Company
</cfquery>
<table>
<cfoutput query="GetCompanies">
<tr>
<td>#CompanyID#</td>
<td>#CompanyName#</td>
</tr>
</cfoutput>
</table>
Basically, ColdFusion performs a query against the MyDatabase datasource (an object that connects to and communicates with a database) and names the data result set (the data that results from performing the query) GetCompanies. Then, for each row in the GetCompanies query, ColdFusion outputs the HTML markup used to format an HTML table row containing two table cells. The first table cell contains the value of CompanyID, and the second table cell contains the value of CompanyName from the current row in the result set.
Hi buddy, I am here to read your articles.
ReplyDelete