Skip to main content
Inspiring
December 17, 2012
Question

nex/previous

  • December 17, 2012
  • 1 reply
  • 705 views

Hi,

i have the simple form for user to enter in PurNo.  Results is displayed fine with next and previous navigation.  without order by from the query, the next/previous worked fine.  However, afer i added  order by PurNo, NesID into my query then navigation didn't work as expected.  for example, when i click next, i see it changed for message and date added column but not for Pur No.  Can any one tell me what's wrong ?

Thanks

<!---cfc--->

<cffunction name="sale" returntype="query" access="public">
<cfargument name="PurNo" required="yes" type="numeric" />
   
<cfquery name="qsale" datasource="#variables.dsn#">
     SELECT *
    FROM tblsale
    WHERE PurNo = <cfqueryparam  value="#arguments.so#" cfsqltype="cf_sql_integer" />
    order by PurNo, NesID
    </cfquery>

    <cfreturn qsale />
</cffunction>

<!--cfm-->

<cfobject type="com" name="request.sale" component="cfc.query">
<cfset variables.request.sale = request.so_expected.init(variables.dbsource) />
<cfset variables.q_sale = request.sale.sale(PurNo ) />

<cfset nav = request.sale.nextXpage(variables.q_sale.recordcount,URL.page,10) />

<cfif nav.previous>
    <a href="next.cfm?PurNo=#PurNo#&page=#nav.previouspage#">Previous</a>
</cfif>
<cfif nav.next>
    <a href="next.cfm?PurNo=#PurNo&page=#nav.nextpage#">Next</a>
</cfif>


<th>Pur No.</th>
<th>Message.</th>
<th>Date Added</th>

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
December 22, 2012

First of all, correct the typing errors. Then we can continue from there, if still necessary.

The errors:

<cffunction name="sale" returntype="query" access="public">

<cfargument name="PurNo" required="yes" type="numeric" />

  ...

... 

WHERE PurNo = <cfqueryparam  value="#arguments.so#" cfsqltype="cf_sql_integer" />

The function's argument is PurNo, however the query uses arguments.so instead.

<a href="next.cfm?PurNo=#PurNo&page=#nav.nextpage#">Next</a>

You probably meant

         <a href="next.cfm?PurNo=#PurNo#&page=#nav.nextpage#">Next</a>

Also, you should scope the variables appropriately, in particular, PurNo.