Professional Web Applications Themes

Search results - Coldfusion Database Access

When i search it returns all the rows; not the ones i've searched for. Any help would be appreciated. do i end my search page with CFM also? <cfparam name="PageNum_Recordset1" default="1"> <cfquery name="Recordset1" datasource="CompanyInfo"> SELECT * FROM Departmt </cfquery> <cfset MaxRows_Recordset1=10> <cfset StartRow_Recordset1=Min((PageNum_Recordset1-1)*MaxRows_Recordset1+1,Max(Recordse t1.RecordCount,1))> <cfset EndRow_Recordset1=Min(StartRow_Recordset1+MaxRows_ Recordset1-1,Recordset1.Record Count)> <cfset TotalPages_Recordset1=Ceiling(Recordset1.RecordCou nt/MaxRows_Recordset1)> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; cht=iso-8859-1"> <title>Untitled Doent</title> </head> <body> <table border="1"> <tr> <td>Dept_ID</td> <td>Dept_Name</td> <td>Location</td> </tr> <cfoutput query="Recordset1" startRow="#StartRow_Recordset1#" maxRows="#MaxRows_Recordset1#"> <tr> <td>#Recordset1.Dept_ID#</td> <td>#Recordset1.Dept_Name#</td> <td>#Recordset1.Location#</td> </tr> </cfoutput> And my search page: <form action="results.cfm" method="post" name="Forum" id="Forum"> <input name="frmIn_DPT_ID" type="text" id="frmIn_DPT_ID"> <input ...

  1. #1

    Default Search results

    When i search it returns all the rows; not the ones i've searched for. Any help
    would be appreciated.
    do i end my search page with CFM also?

    <cfparam name="PageNum_Recordset1" default="1">
    <cfquery name="Recordset1" datasource="CompanyInfo">
    SELECT *
    FROM Departmt
    </cfquery>
    <cfset MaxRows_Recordset1=10>
    <cfset
    StartRow_Recordset1=Min((PageNum_Recordset1-1)*MaxRows_Recordset1+1,Max(Recordse
    t1.RecordCount,1))>
    <cfset
    EndRow_Recordset1=Min(StartRow_Recordset1+MaxRows_ Recordset1-1,Recordset1.Record
    Count)>
    <cfset
    TotalPages_Recordset1=Ceiling(Recordset1.RecordCou nt/MaxRows_Recordset1)>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; cht=iso-8859-1">
    <title>Untitled Doent</title>
    </head>

    <body>
    <table border="1">
    <tr>
    <td>Dept_ID</td>
    <td>Dept_Name</td>
    <td>Location</td>
    </tr>
    <cfoutput query="Recordset1" startRow="#StartRow_Recordset1#"
    maxRows="#MaxRows_Recordset1#">
    <tr>
    <td>#Recordset1.Dept_ID#</td>
    <td>#Recordset1.Dept_Name#</td>
    <td>#Recordset1.Location#</td>
    </tr>
    </cfoutput>

    And my search page:
    <form action="results.cfm" method="post" name="Forum" id="Forum">
    <input name="frmIn_DPT_ID" type="text" id="frmIn_DPT_ID">
    <input type="submit" name="Submit" value="Submit">
    </form>

    Bskyweb Guest

  2. #2

    Default Re: Search results

    > When i search it returns all the rows; not the ones i've searched for. Any
    help
    > would be appreciated.
    > do i end my search page with CFM also?
    Try this:

    <cfquery name="Recordset1" datasource="CompanyInfo">
    SELECT *
    FROM Departmt
    WHERE 1=1
    <cfif StructKeyExists(Form, "frmIn_DPT_ID")>
    AND Dept_Name like <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
    value="%#form.frmIn_DPT_ID#%">
    </cfif>
    </cfquery>

    It will search for the entered keywords in department names.

    --
    <mack />


    Neculai Macarie Guest

  3. #3

    Default Re: Search results

    Thanks, worked like a charm (well... one that works anway...)
    Bskyweb Guest

  4. #4

    Default Re: Search results

    Ok,
    Now i need to search a column called keywords, this is what i hve tried:



    <cfquery name="Recordset1" datasource="GOV">
    SELECT *
    FROM GOV_Table
    WHERE 1=1
    <cfif StructKeyExists(Form, "frmIn_DPT_ID")>
    AND Keywords like <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
    value="%#form.frmIn_DPT_ID#%">
    </cfif>
    </cfquery>

    <cfoutput query="Recordset1" startRow="#StartRow_Recordset1#"
    maxRows="#MaxRows_Recordset1#">
    <tr>
    <td>#Recordset1.File_Name#</td>
    <td>#Recordset1.URL_of_file#</td>
    </tr>
    </cfoutput>
    For the cfoutput i didnt want it to show the Keywords so i deleted the column,
    Is that ok?


    And my search Page is the same as before

    Bskyweb Guest

Similar Threads

  1. Clikckabel Search Results
    By Bskyweb in forum Coldfusion Database Access
    Replies: 1
    Last Post: August 15th, 07:23 PM
  2. Sending search results to a results page..with asp
    By dan.how in forum Dreamweaver AppDev
    Replies: 1
    Last Post: May 26th, 04:18 PM
  3. search results pages
    By Jomo in forum Macromedia ColdFusion
    Replies: 1
    Last Post: February 19th, 12:35 AM
  4. Help with search results in asp vbs
    By Chris in forum Dreamweaver AppDev
    Replies: 2
    Last Post: February 17th, 09:57 PM
  5. Search within Search Results
    By Maria Kovacs in forum ASP Database
    Replies: 1
    Last Post: October 7th, 04:45 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139