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
Solved

Read a string value

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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 …
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 …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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