Solved

Read a string value

Posted on 2003-10-30
4
138 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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 …
What You Need to Know when Searching for a Webhost Provider
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

622 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