Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    cfm Query not working

    Hi all..what i'm trying to a simple search function....there prolem is my result page(testsearch2.cfm) won't

    display the result at all...well here my code..can anybody please comment

    first page(testsearch1.cfm)

    <html>
    <head>
    </head>
    <body>
    <form name="form1" method="post" action="testsearch2.cfm">
    Search on
    <select name="fieldname" id="fieldname">
    <option value="full_name" selected>Employee Name</option>
    <option value="emp_no">Employee No</option>
    </select>
    for
    <input name="sitem" type="text" id="sitem">
    <input type="submit" name="Submit" value="Submit">
    </form>
    </body>
    </html>

    second or result page(testsearch2.cfm)

    <html>
    <head>

    <cfquery name="result" datasource="epa">
    Select * from employee where "#Form.fieldname#"="#Form.sitem#"
    </cfquery>
    </head>

    <body>
    <cfoutput>#result.emp_no#</cfoutput>
    </body>
    </html>

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    What do you mean by "won't display"?
    Do you get an error? If so, what?
    If you don't get an error, are you sure there really are matches? This query will be case-sensitive and does not do partial matching.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Regular Coder
    Join Date
    Feb 2005
    Location
    UK
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Couple of small problems, don't know if it would have stopped it from working, but this should work:

    Code:
    <cfquery name="result" datasource="epa">
    Select * from employee where #Form.fieldname#='#Form.sitem#'
    </cfquery>
    
    <cfoutput query="result">#result.emp_no#</cfoutput>


  •  

    Posting Permissions

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