Solved

Read a string value

Posted on 2003-10-30
4
134 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…

749 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