www.webdeveloper.com
Results 1 to 3 of 3

Thread: ColdFusion Query

  1. #1
    Join Date
    Dec 2006
    Posts
    7

    ColdFusion Query

    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

  2. #2
    Join Date
    Dec 2006
    Location
    Escaz˙ (Costa Rica) and Mallorca (Spain)
    Posts
    3,234
    Code:
    <cfif CGI.HTTP_REFERER IS NOT "my_previous_page.cfm">
      <!--- Wrong page --->
    <cfelse>
      <!--- Process data  --->
    </cfif>

  3. #3
    Join Date
    Jul 2007
    Location
    Tampa, FL
    Posts
    5

    You Are Missing the name of the form, the form element, & the query is wrong

    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>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles