An E - Rolodex System

Almost everybody who uses a data-driven website has a database containing some information about the users. 
I had a database table called "contact" in which user's first name, last name, address, zip, email, phone, fax.... everything was listed.
If you do have something like that and wish to draw and group your contacts by say last names, maybe you will find this tutorial useful. 

___________________________
CREATE FIRST FILE : "dir.cfm" 
___________________________
Create the first file "dir.cfm" 
Then create a cold fusion form. Within the form create 26 buttons with 
NAME= "same for all buttons" and VALUE="alphabets from A-Z" as shown in the example


<html>
  <head>
     <title>
DIRECTORY</title>
  </head>

  <body>


  <cfform action="list.cfm" method="POST" enablecab="Yes">

<input type="hidden" name="option" value="0">
<input type=
"SUBMIT" name="a" value="A">
<input type=
"SUBMIT" name="a" value="B">
<input type=
"SUBMIT" name="a" value="C">
<input type=
"SUBMIT" name="a" value="D">
<input type=
"SUBMIT" name="a" value="E">
<input type=
"SUBMIT" name="a" value="F">
<input type=
"SUBMIT" name="a" value="G">
<input type=
"SUBMIT" name="a" value="H">
<input type=
"SUBMIT" name="a" value="I">
<input type=
"SUBMIT" name="a" value="J">
<input type=
"SUBMIT" name="a" value="K">
<input type=
"SUBMIT" name="a" value="L">
<input type=
"SUBMIT" name="a" value="M">
<input type=
"SUBMIT" name="a" value="N">
<input type=
"SUBMIT" name="a" value="O">
<input type=
"SUBMIT" name="a" value="P">
<input type=
"SUBMIT" name="a" value="Q">
<input type=
"SUBMIT" name="a" value="R">
<input type=
"SUBMIT" name="a" value="S">
<input type=
"SUBMIT" name="a" value="T">
<input type=
"SUBMIT" name="a" value="U">
<input type=
"SUBMIT" name="a" value="V">
<input type=
"SUBMIT" name="a" value="W">
<input type=
"SUBMIT" name="a" value="X">
<input type=
"SUBMIT" name="a" value="Y">
<input type=
"SUBMIT" name="a" value="Z">

</cfform>

</body>
</html>


______________________________
CREATE SECOND FILE : "list.cfm" 
______________________________

Then create a second file "list.cfm" with the query and and listing values in it, as follows;

<!--- this was my query to the directory dsn --->
<cfquery name="dir" datasource="YOUR DSN" dbtype="ODBC">
   Select   *
   from      contact
  where    contact.l_name like '#form.a#%'
</cfquery>

<!--- if you know some basic SQL a% will give you the values starting from "A"
b% will give those starting from "B" and so on. 
You can even tweak the "dir.cfm" page to search by last name or first name. For our purpose here I have only searched by Last Names --->


<html>
  <head>
    <title>
LISTINGS</title>
  </head>

  <body>
  <div align=
"center">
  <cfinclude template="dir.cfm">
  <hr>
<!--- the rest of it is simple use of cfoutput tags and aligning the query results to you liking. I have done it in a single row of a table. But you may set it to look differently. --->

Found records: <cfoutput>#dir.recordcount#</cfoutput><br>
<!--- counts number of records found --->


<table width="100%">
  <tr align=
"center" valign="middle" bgcolor="eeeeff">
    <td>
COUNT</td>
    <td>
NAME</td>
    <td>
URL</td>
    <td>
EMAIL</td>
    <td>
ADDRESS</td>
    <td>
PHONE</td>
  </tr> 
 
<cfoutput query="dir">
 
<cfform action="directory.cfm" method="POST" enablecab="Yes"
  <tr bgcolor=
"###iif(currentrow MOD 2,DE('ffffff'),DE('efefef'))#">
    <td>
#currentrow#</td>
    <td>
#f_name# #l_name#</td>
    <td>
#web_page#</td>
    <td>
#email#</td>
    <td>
#address_1#
          #address_2#<br>
          #city#,#state#-#zip#
    </td>
    <td>
#phone#</td>
  </tr>
</cfform>
</cfoutput>

</table>

</div>
</body>
</html>




All ColdFusion Tutorials By Author: ANANG PHATAK
  • An E - Rolodex System
    Quick and easy way to sort and list your contacts by last names, in two really really simple steps. Almost everybody who uses a data-driven website has a database containing some information about the users. I had a database table called "contact" in which user's first name, last name, address, zip, email, phone, fax.... everything was listed. If you do have something like that and wish to draw and group your contacts by say last names, maybe you will find this tutorial useful.
    Author: ANANG PHATAK
    Views: 9,700
    Posted Date: Friday, November 7, 2003