Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Passing Queries

    This is the first time I am posting here so I hope nobody panics if this is the
    wrong section for this question......

    Anyway, I have created a basic search using coldfusion 6.1 and mysql. There is
    a form with 6 different search criteria and the results get posted to the same
    page right under the search box. The search itself works fine and returns the
    correct data based on what was entered. The problem lies when I tried to break
    the results into 10 returns per page and using a next-n records interface to go
    through the records page by page.

    The name of the form is 'thisForm'. It is a basic form that just submits to
    the same page.
    There are 4 hidden fields so far. They are:

    <input type="Button" name="clearForm" value="CLEAR FORM" id="n10"
    style="width: 130px;" onClick="clearThisForm();">&nbsp;&nbsp;
    <input type="Submit" name="submitButton" value="SUBMIT SEARCH" id="n10"
    style="width: 130px;">
    <input type="hidden" name="submitSearch" value="1">
    <input type="Hidden" name="StartRow" value="#form.StartRow#">

    Next I have some logic that will run if the form is submitted. The first thing
    I include is the query
    <CFINCLUDE TEMPLATE="tranTypeQueries.cfm">
    that grabs the info depending on which search criteria was entered.
    Next I have another cfif that reads
    <CFIF getSearchResults.RecordCount GT 0>
    It will do some stuff including the following
    <CFSET RowsPerPage = 10>
    <CFPARAM name="form.StartRow" DEFAULT="1" TYPE="numeric">
    <CFSET TotalRows = getSearchResults.RecordCount>
    <CFSET EndRow = Min(form.StartRow + RowsPerPage - 1, TotalRows)>
    <CFSET StartRowNext = EndRow + 1>
    <CFSET StartRowBack = form.StartRow - RowsPerPage>
    And this is also included as well.
    <CFINCLUDE TEMPLATE="NextIncludeBackNext.cfm">

    And the NextIncludeBackNext.cfm has the following in it
    <CFIF StartRowNext LTE TotalRows>
    <a href="##" onclick="document.thisForm.StartRow.value=#StartRo wNext#;
    document.thisForm.submit(); return false;" >NEXT></a>
    </CFIF>


    So here is what happens ...... Like I said I can search and get results. This
    is fine but when I click NEXT to show records 11 thru 20 it just says that
    "Element RECORDCOUNT is undefined in GETSEARCHRESULTS"
    So what I can tell so far is that the variables are being passed ok but the
    search results are not.
    Does anyone have any advice on how to resolve this issue? And it kinda has to
    be fixed without removing the javascript stuff.

    raven62 Guest

  2. Similar Questions and Discussions

    1. Can't run queries
      I have a new development machine I have set up that has the same environment as my current machine. The database gives an "ok" status in the CF 7...
    2. Queries
      hi all, i am using the tutorial: Creating Dynamic Playlist and able to play it correctly, when i open the swf file and i observe that there is 6...
    3. Queries Of Queries Single Quote Problem
      When using queries of queries I'm having the following issue. Select Company_ID From qry_MyQuery Where Company_NM = 'MyString''s' <----...
    4. Passing Query Parameters in Sub-Queries
      coder23 wrote: '1/1/2004' ??? Shouldn't it be #'1/1/2004# ? Or are these Text parameters? You need to create another saved query for this: ...
    5. HELP! Passing from database to asp page allowing user input then passing to another database.
      My big problem is I'm a newbie working with someone else's code.(See code below) What I want to do is for the records that have a purchase order...
  3. #2

    Default Re: Passing Queries

    Hi Raven

    Pretty sure you can't pass a complex object (like a query) as a form
    parameter. You'll either have to perform the query on each page or put it into
    a session variable as soon as you create it (should put CFLOCK tags around all
    writes and reads to the session variable too).

    First page would run the query to get the search results and create the
    session variable.
    <CFSET Session.GetSearchResults = GetSearchResults>

    Then on each subsequent page check if the session variable exists as a query
    and use it as your search results.
    <CFIF IsDefined("Session.GetSearchResults") AND
    IsQuery(Session.GetSearchResults)>
    <CFSET GetSearchResults = Session.GetSearchResults>
    <CFELSE>
    Do search query again or go back to search page.
    </CFIF>

    HTH

    Zoe

    zoeski80 Guest

Posting Permissions

  • You may not post new threads
  • You may 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