This tutorial will demonstrate how to query a database and then display them on your site in order.

When you need to retrieve and display records from a database, ColdFusion is the easiest and fastest way to do so, simply because it takes less coding then all other developers languages to do so.  In this tutorial I will demonstrate how to query a database using <CFQUERY> and then display the records using <CFOUTPUT>.  Let's begin:

The first step that is involved is querying the database for all of the records that exist.

<!--- Query The Database For All Records In That Table --->
   SELECT          *
   FROM             TableName
   ORDER BY      FieldName

   #GetRecords.CurrentRow#)  #FieldName# - #FieldDescription#<BR>

That code above will query your database for all records in the table "TableName" and return them to be displayed on your page.  Notice that I simply put the name of the fields within that table and surrounded them with # signs.  The # signs tell ColdFusion to process for the values when they are within a <CFOUTPUT> tag.  Another thing I did was use the code:
#GetRecords.CurrentRow#, this simply let's ColdFusion server that you want the number of the current record being displayed, that way you can show your results in order with numbers to the left as in the example below.

1) Pablo - This is User Number 1
2) Jessica - This is User Number 2
3) Tony - This is User Number 3

That is how easy and fast you can begin using ColdFusion to make your database interact with your web pages.

About This Tutorial
Author: Pablo Varando
Skill Level: Beginner 
Platforms Tested: CF5
Total Views: 148,078
Submission Date: August 03, 2002
Last Update Date: June 05, 2009
All Tutorials By This Autor: 47
Discuss This Tutorial
  • if you are using , you can refuse to use #GetRecords.CurrentRow#), since the cfoutput already spesific which query it will retrieve from. Just using #CurrentRow#), and that's work.

  • after i've entered the required data, and pressed 'ok', i get this message: TypeError: this.node has no properties i've asked around, but haven't been able to get an answer. what is blocking my query?

  • when i try to get my database table in to web i face some difficulties... what can i do... this is appear in browser Error Executing Database Query. [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. Please try the following: Enable Robust Exception Information to provide greater detail about the source of errors. In the Administrator, click Debugging & Logging > Debugging Settings, and select the Robust Exception Information option. Check the ColdFusion documentation to verify that you are using the correct syntax. Search the Knowledge Base to find a solution to your problem. Browser Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; v11b.01) Remote Address Referrer Date/Time 29-Jun-04 08:26 PM


Sponsored By...
Mobile App Development (IOS, Android, Cordova, Phonegap, Objective-C, Java) - Austin, Texas Mobile Apps - Touch512, LLC.