Skip to main content
Participant
March 26, 2009
Question

Using a Form to selct from DB

  • March 26, 2009
  • 1 reply
  • 1108 views
Need Help...

Please take a look at this site page and please advise as to which Cold Fusion record set would be the one to use and how. The page is http://www.condraartista.com/select.asp as you can see it is written in active server pages. The result page looks like this http://www.condraartista.com/search.asp.

My database is Microsoft Access 2007

I have been trying so hard in finding the right combination with video tutorial etc. But I gues becuase the form has drop down selectors it seems difficult.

Anyone that can provide assistance is welcomed and appreciated.

R/S

Armando O Ortiz
This topic has been closed for replies.

1 reply

Inspiring
March 27, 2009
there are numerous ways a search form like that can be coded using cf
(or any other language for that matter). which part of creating a search
form are you having trouble with exactly?

just as general examples, here's some sample code:

1) hard-coded search form:
<!--- search form --->
<form ...>
<select name="gender">
<option value="0" selected="selected">Any</option>
<option value="Female">Female</option>
<option value="Male">Male</option>
</select>
...
</form>

<!--- results page --->
<cfparam name="form.gender" default="0">
<cfquery name="getSearchResults" datasourse="...">
SELECT somecolumns
FROM sometable
WHERE 1 = 1
<cfif form.gender neq 0>
AND gender = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.gender#">
</cfif>


2) database-driven search form:
<!--- search form --->
<cfquery name="getGenders" datasource="...">
SELECT 0 AS gender_id, 'Any' AS gender, 1 AS sortcolumn
FROM genders
UNION
SELECT gender_id, gender, 2 AS sortcolumn
FROM genderstable
ORDER BY sortcolumn, gender
</cfquery>

<form ...>
<select name="gender">
<cfoutput query="getGenders">
<option value="#gender_id#" <cfif getGenders.currentrow eq
1>selected="selected"</cfif>>#gender#</option>
</select>

<!--- results page --->
<cfparam name="form.gender" default="0">
<cfquery name="getSearchResults" datasourse="...">
SELECT somecolumns
FROM sometable
WHERE 1 = 1
<cfif form.gender gt 0>
AND gender = <cfqueryparam cfsqltype="cf_sql_integer" value="#form.gender#">
</cfif>


the above examples are just 2 of multitude of possible ways to go about
it...

hth


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Participant
March 29, 2009
Thank you for responding. I am still stuck. I am also new to Cold Fusion or any dynamic building.
I would like to know how the recordset/s need to be made in order to retrieve all the choices that are selected on the form and displayed. Do you have to create a recordset for each drop down choice or is there a way to create a recordset that will choose all the choices and then just click on the submit button and then on another page see all the talent persons you chose?

Please advise...Thanks

Armando.
Inspiring
March 29, 2009
quote:

Originally posted by: Armandotop
Thank you for responding. I am still stuck. I am also new to Cold Fusion or any dynamic building.
I would like to know how the recordset/s need to be made in order to retrieve all the choices that are selected on the form and displayed. Do you have to create a recordset for each drop down choice or is there a way to create a recordset that will choose all the choices and then just click on the submit button and then on another page see all the talent persons you chose?

Please advise...Thanks

Armando.

There are many beginner level tutorials on easycfm.com. Try some of them and you'll get the hang of things.