Solved

Read a string value

Posted on 2003-10-30
4
130 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
Comment Utility
<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
Comment Utility
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
Comment Utility
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
Comment Utility
thanks
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 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

7 Experts available now in Live!

Get 1:1 Help Now