Click to See Complete Forum and Search --> : ColdFusion Query


Zerocool
02-19-2007, 02:48 PM
I have a small problem that is driving me nuts!!

I have an SQL Database set and have a small website that read datfrom it uses ColdFusion.

What I need to do is have a value submitted via a form and the data in the new pages opens up with reference only to the value submitted from the form. (????)


This is the from used :


<FORM action="teamdetails.cfm" TARGET="Blank" METHOD="Post" VALUE="name">
<select size="6">

<option value = "Doulgas">Douglas</option>
<option value = "Rileys">Rileys</option>
<option value = "Railway">Railway</option>
<option value = "OldeMIll">Olde Mill</option>
<option value = "The Vault">The Vault</option>
<option value = "Michelin">Michelin</option>
<option value = "Fairmuir">Fairmuir</option>
<option value = "NorthEnd">North End</option>
<option value = "Whitfield">Whitfield</option>
<option value = "Newport">Newport</option>
<option value = "Tivoli">Tivoli</option>
<option value = "DD1">DD1</option>
</select>

</br>
</br>
<input type="submit" name="teamname" value="Show Me">
</center>
</form>



This is the CF Query on the page "teamdetails.cfm" that will display the data. I want to only dispaly the data that matches the request from the previous page.


<CFQUERY NAME = "info" datasource = "sql_0603051">
SELECT name,clubadd,clubph,captain,captainph,vice,vicepn,notes

WHERE "teamselectedfrompreviousepage" teams.name

FROM teams

</CFQUERY>


any suggestions?

I would also like the window to open up in a new window with no menus etc

TIA

NightShift58
02-25-2007, 08:39 AM
<cfif CGI.HTTP_REFERER IS NOT "my_previous_page.cfm">
<!--- Wrong page --->
<cfelse>
<!--- Process data --->
</cfif>

FSUKXAZ
07-17-2007, 11:04 AM
You Are Missing The Name Of Your Form, and you are missing the name of your Form element, the Form itself shouldn't have a VALUE attribute, and the Output of the query is wrong too. Major coding issues.

<FORM action="teamdetails.cfm" TARGET="Blank" METHOD="Post" NAME="Whatever">
<select NAME="TeamName" size="6">

<option value = "Doulgas">Douglas</option>
<option value = "Rileys">Rileys</option>
<option value = "Railway">Railway</option>
<option value = "OldeMIll">Olde Mill</option>
<option value = "The Vault">The Vault</option>
<option value = "Michelin">Michelin</option>
<option value = "Fairmuir">Fairmuir</option>
<option value = "NorthEnd">North End</option>
<option value = "Whitfield">Whitfield</option>
<option value = "Newport">Newport</option>
<option value = "Tivoli">Tivoli</option>
<option value = "DD1">DD1</option>
</select>

</br>
</br>
<input type="submit" name="teamname" value="Show Me">
</center>
</form>


On the other page. It is not wise to abbreviate all the field names of your table. Don't be lazy, do the right thing and spell them out completely like "CaptainPhone" or "captain_phone" not captainph. It's way too ambiguous. Lastly, you MUST change the field "name" to something like "TeamName" or "team_name", because if you look at the code for the first page it will say Name="name". That can cause serious issues, so here below I'm doing it for you.

<CFQUERY NAME = "info" datasource = "sql_0603051">
SELECT teamName,clubadd,clubph,captain,captainph,vice,vicepn,notes
FROM teams
WHERE teamName = "#Form.TeamName#
</CFQUERY>