• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

nex/previous

Explorer ,
Dec 17, 2012 Dec 17, 2012

Copy link to clipboard

Copied

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>

TOPICS
Advanced techniques

Views

629

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 22, 2012 Dec 22, 2012

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation