Skip to main content
Known Participant
April 16, 2007
Question

cf search

  • April 16, 2007
  • 24 replies
  • 2203 views
Hi, my name is Andy and I know just enough about web design & server-side, client-side stuff to get very frustraited.
I don't need anything too fancy (at least at first). I dont need the client to write to the database and I don't need the data base to change.
Here is what I do need:
On my home page I need the client to have a search box to enter thier zip code (which I guess I need to make my primary key) to find an electrician in thier area which may or may not be there depending on wheter we have one in our data base or not.
If one is there then I need a form to pop up for thier info. When the form is submitted, it needs to SMS to that member's cell phone.
Note: I have all of the network strings for the different phone company carriers but I know there is probably an easier way to do it with CF. For now though, I just need to know how to put a search box on my home page that will query the zip of the different members in my db. Thanks, Andy
This topic has been closed for replies.

24 replies

April 17, 2007
You use the term "PostalCode", which makes me think this value can have alpha characters and/or spaces in it, like Canadian postal codes. If so, you must remove the IsNumeric( ) test in the CFIF tag.
Inspiring
April 17, 2007
ace4u wrote:
> YAHOO!!!
> I just got it with this line:
> WHERE "#FORM.myZip#" = EleContractorInfo.PostalCode
> THANK YOU!!! THANK YOU!!! THANK YOU!!!
>
> Now, I think I know how to turn the results in to a link but how do I link to
> a form that will point to each contractor's SMS individually? Or a form to
> anything really?
> And just so I know- what does this line do?
>
> <CFIF getElectrician.RecordCount IS NOT 0> ???
>
>

that line checks if the getElectrician query returned any data, in your
case that is if an electrician was found in selected zip area.

as for how to link to a form - that depends on what you want the form to
do. from your previous posts i gather that you would like the user, if
an electrician is available in user's zip area, to fill out user's
details to contact the electrician.

you will then put a link next to each found electrician to some other
page with a contact form, i.e. contact.cfm, with each electrician's
unique id from your db (contractor_id field, i believe) in the url query
string, like:
<a href="contact.cfm?eid=#contractor_id#>Contact this Electrician!</a>

on the contact.cfm page you will have your form for the user to fill
out. that form should have a hidden text input field that will store the
eid value passed from the previous page in the url query string. once
the user fills out the form and clicks submit, your action page will
query the db to retrieve the electrician's sms or other details (based
on the value of that hidden form field with eid value) and send an sms
to him/her or do whatever else you want it to do.

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com
ace4uAuthor
Known Participant
April 17, 2007
YAHOO!!!
I just got it with this line:
WHERE "#FORM.myZip#" = EleContractorInfo.PostalCode
THANK YOU!!! THANK YOU!!! THANK YOU!!!

Now, I think I know how to turn the results in to a link but how do I link to a form that will point to each contractor's SMS individually? Or a form to anything really?
And just so I know- what does this line do?

<CFIF getElectrician.RecordCount IS NOT 0> ???
ace4uAuthor
Known Participant
April 17, 2007
HERE IS WHAT I HAVE:
_______________________________________________
<CFIF FORM.myZip IS NOT "" AND IsNumeric(FORM.myZip)>
<CFQUERY NAME="getElectrician" DATASOURCE="enet1" >
SELECT *
FROM EleContractorInfo

</CFQUERY>
<CFIF getElectrician.RecordCount IS NOT 0>
<CFOUTPUT QUERY="getElectrician">
#CompanyName# <BR>
#StreetNumber#<br>
#City#<br>
#State#<br>
#Contact_Phone#

</CFOUTPUT>
<cfelse>
There is no electrician in your area.
</cfif>
<cfelse>
<div align="center" class="style1">You did not enter a numeric zip code.</div>
</cfif>
ace4uAuthor
Known Participant
April 17, 2007
Hi.
I have been playing with the form all night. Maybe I'm taking something too litterally in the strings.
I have found that the "WHERE" statement (WHERE zip = #FORM.myZip#) does not work no matter what I do with it. I tried to make it "WHERE FORM.myzip = ElectricalContractor.PostalCode" (with and without ##) no combination works.
Also, I played with this switch:
<CFIF getElectrician.RecordCount IS NOT 0>
I either get both records in my db (both of my companies) or I get "There is no contractor in your area.
What I'm trying to get is the record that matches the zip. Thanks again, Andy
ace4uAuthor
Known Participant
April 16, 2007
Context validation error for tag CFELSE.
The tag must be nested inside a CFIF tag.
ace4uAuthor
Known Participant
April 16, 2007
One last thing.
In the intrest of not wasting too much more of your time please allow me to be a bit more specific.
I have a data base setup called "enet1.mdb" This db has one important table called "Electrical_Contractor_Info" which lists columbs for contractor_ID, contractor_name, address, city, state, postal_code respectively. There is another table called "contractor_link" which has contractor_ID and contractor_SMS. But lets just say I have the 1st table and I want the client to enter thier zip (matching the postal_code columb) to render all of the results of the electrical_contractor_info table. How can I do that? I'm sorry but I guess I'm asking you to put the cookies on the lower shelf.
ace4uAuthor
Known Participant
April 16, 2007
No- I'm just trying to render the results of the db directly on to the page.
i.e. if they type 33617 in to the search field and my db shows 33617 as acme electric, i want it to render a link masked as "ACME EL." but actually point to
555-555-5555@AcmeElectric'sCellCarrier.com.
My db already has a table setup with the values. I just dont know how to query it and get the correct output. However, I do relize that you have no idea what my tables are actually titled so I'm continuing to work with what you sent. Thanks, Andy
April 16, 2007
On the form page - post the exact line of code that has the <INPUT TYPE="text" NAME="myZip" ... > in it. Are you trying to populate the form field with a value? Regarding CFFORM, I don't use it. Mostly a matter of taste, although it can make validation easier.
ace4uAuthor
Known Participant
April 16, 2007
ok, i got it to find the form but I got this new CF error:Element MYZIP is undefined in FORM.
What should myzip refer to? Can I get the page to render the results of the db directly. My pages are connected to the db at this point.