Ask a Question related to Coldfusion Database Access, Design and Development.
-
raven62 #1
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();">
<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
-
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... -
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... -
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' <----... -
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: ... -
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... -
zoeski80 #2
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



Reply With Quote

