Solved

Read a string value

Posted on 2003-10-30
4
131 Views
Last Modified: 2013-12-24
Hi experts:

I have a form field for zipcode in US. My problem is that sometimes people tend to put in the post box number after the zip code, like 12345-4444. I'm using the first 5 digits to compare it with a zip code database i have here and then send the user to a particular page. How can I just read the first 5 digits of the zip code field and then compare it with a table in the DB and construct a query? I'm not sure if I'm clear enough.
0
Comment
Question by:adonis1976
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
jyokum earned 500 total points
ID: 9650103
<cfquery name="myQuery" datasource="whatever">
SELECT columnA, columnB
FROM tablename
WHERE zipcode = <cfqueryparam value="#left(form.zipcode,5)#" cfsqltype="cf_sql_numeric">
</cfquery>

-assuming your form field is named zipcode
0
 
LVL 6

Expert Comment

by:PE_CF_DEV
ID: 9650171
jyokum hit it right on the head, just to give some flavor though, assuming your visitors always use the - you can do listfirst(form.zipcode,'-'). jyokum's is more reliable though.
0
 
LVL 11

Author Comment

by:adonis1976
ID: 9650200
jyokum:

I just increased points this question to 500 points just to say thanks to your great help. It just worked like a champ. I thought you deserved more than 250 points for answering this question so quickly. Thanks again.
0
 
LVL 12

Expert Comment

by:jyokum
ID: 9650445
thanks
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
json_decode return null? 8 69
Internal DNS Zone Issue 13 59
Asp.net plan security, reliable, stable 2 110
IIS url rewrite rule for web application 3 52
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now