×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Database Field Output

Outputting bit efficiently by webmigit
Posted: 7 Nov 03

Unless you're programming for your own website where you know what the value means, when you display the value of a bit (yes/no) database field on a page you probably run something like this..

<cfif query.bitparam eq 0>
Not allowed
<cfelse>
Allowed
</cfif>


Which is typically what I do too but I have an output of about 400 rows in one site which has 4 bit values for each row.. meaning 1600 cfifs...

I don't like that...

So what I do when I have cases like that is..

<cfset ArrBool=ArrayNew(1)>
<cfset ArrBool[1]="Not Allowed">
<cfset ArrBool[2]="Allowed">


before any cfloops or cfoutputs

And then in my output of the bit field I say..

#ArrBool[bitfieldname+1]#

If the value is 0, it will read dimension one because of the + 1, if the value is 1, it will read dimension two because of the +1.

Plus I can use that on all four bits outputted four hundred times so I'm saving a lot of cfifs.

I haven't ran a timer on the page to find out.. haven't studied it in depth but I know two things.. It appears much faster to me and everyone else looking at the page on any computer and it makes adding another bit field and outputting even easier than the common cfif/cfelse.

Enjoy!

Back to Adobe FAQ Index
Back to Adobe Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close