Give this a shot - should get you on the right track.

==============================================================
<cfscript>
i=1;
fname=ArrayNew(1);
lname=ArrayNew(1);
if(not isdefined("url.orderby")){
        url.orderby="fname";
}
if(not isdefined("url.updn")){
        updn="ASC";
}
</cfscript>

<cfquery name="qGetAll" datasource="#request.dsn#">
SELECT fullname
FROM mytable
</cfquery>

<cfoutput query="qGetAll">
        fname[i]=ListGetAt(fullname,1," ");
        lname[i]="ListGetAt(fullname,2," ")";
        <cfset i=i+1>
</cfoutput>

<cfscript>
tmp=QueryAddColumn(qGetAll, "fname", fname);
tmp=QueryAddColumn(qGetAll, "lname", lname);
</cfscript>

<cfquery name="qGetAll_2" dbtype="query">
SELECT * FROM qGetAll
ORDER BY #url.orderby# #url.updn#
</cfquery>

<cfscript>
if(updn is "ASC"){
        updn="DESC";
}else{
        updn="ASC";
}
</cfscript>

<cfoutput query="qGetAll_2">
<a href="mypage.cfm?sortby=fname&updn=#updn#">#fname#</a> 
<a href="mypage.cfm?sortby=lname&updn=#updn#">#lname#</a>
<br>
</cfoutput>
==============================================================

Hope this helps!

Joshua Miller
Web Development :: Programming
Eagle Web Development LLC
www.eaglewd.com
[EMAIL PROTECTED]
(304) 622-5676 (Clarksburg Office)
(304) 456-4942 (Home Office)


-----Original Message-----
From: Jeff Fongemie [mailto:[EMAIL PROTECTED]] 
Sent: Monday, May 13, 2002 12:05 PM
To: CF-Talk
Subject: can this be done?


Hello cf-talk,

  I have an existing project where a form takes a field "name" and
  inserts in in a row "name" in an Access database.

  So, we have about 1000 names in the database as one name (firstname
  lastname). Now, the client changes
  his mind, and wants to be able to sort by last name, firstname.

  Yes, this was discussed prior to, and was deemed not needed.

  Is there a way, to somehow break up the full name into 2 fields, say
  by using the space as a separator?  I would only need to do this
  once as it is an event. Could I make two new fields, last_name and
  first_name, then get the fullname, break it up using the space, then
  insert first_name, then last_name?

  Is this even possible? This would have been so much easier if client
  said yes to this at the design stage!


Best regards,
 Jeff Fongemie                          mailto:[EMAIL PROTECTED]


_____________________________________________________
Composed on Monday, May 13, 2002, at 11:55:57 AM


______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to