Skip to main content
Inspiring
May 12, 2009
Question

list paging error.

  • May 12, 2009
  • 4 replies
  • 1199 views

Hello, I am trying to create record set that lists seven records per page which it does. I have created previous and next links and they display but when I click on the next link I get an error message . . .  Variable ID is undefined. ID is the field that query sorts by and I do not see why it is undefined. Please see code - thanks-jim

<cfquery name="results" datasource="WebDataSource">
SELECT ID, Product, Description, County
FROM Feedback 
Where 0=0
AND ID LIKE '%#ID#%'
AND Product LIKE '%#Product#%'
AND Description Like '%#Description#%'
and County like '%#County#%'
Order by ID
</CFQUERY>

<cfparam name="url.startrow" default="1"/>


  <cfset nNextStartRow = URL.startrow + 7 />


<cfset nPreviousStartRow= URL.startrow - 7 />
 
  <cfoutput> <h3>Returned #results.recordcount# reports submitted</h3>  </cfoutput>

   
           
            <cfoutput><table summary="County user feedback reports"      
       
               
                  <cfif nPreviousStartRow GTE 1>
       
        <a href="#CGI.SCRIPT_NAME#?startrow=#nPreviousStartRow#">Previous</a>

          </cfif></td>
        <td><a href="#CGI.SCRIPT_NAME#?startrow=#nNextStartRow#">Next</a></td>
        </tr>


        </cfoutput

   
      <CFOUTPUT Query="results" startrow="#url.startrow#" maxrows="7">
   
    <tr>
  <th width="10%" scope="col">ReportID:</th>
  <th width="12%" scope="col">County:</th>
        <th width="12%" scope="col">Product:</th>
  <!---<th width="66%" scope="col">Description:</th>--->
</tr>
   
    <tr>
  <td>#id#</td>
        <td>#county#</td>
        <td>#product#</td>
      <!---' <td>#description#</td>--->
      </tr>
        <tr >
        <td bgcolor="##FFFFCC" colspan="3"><strong>Description:</strong> #description#</td></tr>
 
  </cfoutput></table>

    This topic has been closed for replies.

    4 replies

    rockhikerAuthor
    Inspiring
    May 15, 2009

    hi again,

    I tried using the method below. but it returns error: ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.


    The error occurred in C:\Webroot\Crabweb1a\Technology\Mobility\pgs\feedback_details.cfm: line 18

    16 :        AND County like '%#County#%'
    17 :       
    18 : </cfif>Order by reportID,county
    19 :    </cfquery>
    20


    <cfquery name="results" datasource="MobWebDataSource">
            SELECT ID, Product, Description, County
            FROM mobilityFeedback
            Where 0=0
    <cfif IsDefined("reportID")>
            AND reportID LIKE '%#reportID#%'
    </cfif>
    <cfif IsDefined("Product")>
            AND Product LIKE '%#Product#%'
    </cfif>
    <cfif IsDefined("Description")>
            AND Description Like '%#Description#%'
    </cfif>
    <cfif IsDefined("County")>
            AND County like '%#County#%'
          
    </cfif>Order by reportID,county
        </cfquery>

    Message was edited by: rockhiker

    Message was edited by: rockhiker

    rockhikerAuthor
    Inspiring
    May 18, 2009

    Still have not go this to work.  I have the web constuction kit books and they seem a little too much to digest Can anyone reccommend a good book for a beginner- thks jim

    rockhikerAuthor
    Inspiring
    May 13, 2009

    i  tried using form.ID but had no luck. Can anyone point me to where and how should define it. ? thks

    jim

    Inspiring
    May 13, 2009

    Did you try using the the query name instead of the 'form' scope?

    rockhikerAuthor
    Inspiring
    May 13, 2009

    I tried using the query name but the error is actually in the query: ReportID is a number. It is weird because the query works to display the results list but when I click the next page link the error below is returned. Is something missing here? thks - jim

    The error occurred in C:\Webroot\Crabweb1a\Technology\Mobility\pgs\feedback_details.cfm: line 117
    115 : FROM mobilityFeedback  
    116 : Where 0=0 
    117 : AND reportID LIKE "%#reportID#%"
    118 : AND Product LIKE '%#Product#%' 
    119 : AND Description Like '%#Description#%

    <cfquery name="results" datasource="WebDataSource">
    SELECT reportID, Product, Description, County
    FROM mobilityFeedback 
    Where 0=0
    AND reportID LIKE '%#reportID#%'
    AND Product LIKE '%#Product#%'
    AND Description Like '%#Description#%'
    and County like '%#County#%'
    Order by ReportID

    </CFQUERY>

    <cfparam name="URL.startrow" default="1"/>
      <cfset nNextStartRow = URL.startrow + 7 />
    <cfset nPreviousStartRow= URL.startrow - 7 />

    <table summary="County user feedback reports">
        <cfoutput>
        <tr>
        <td>
         <cfif nPreviousStartRow GTE 1>
        <a href="#CGI.SCRIPT_NAME#?startrow=#nPreviousStartRow#">Previous</a></cfif></td>
        <td><a href="#CGI.SCRIPT_NAME#?startrow=#nNextStartRow#">Next</a></td>
       
        </tr>
        </cfoutput>
           
                   
        <tr>
      <th width="12%" scope="col">ReportID:</th>
      <th width="12%" scope="col">County:</th>
            <th width="12%" scope="col">Product:</th>
     
    </tr>
           
                           
           <CFOUTPUT Query="results" startrow="1" maxrows="7">
              </cfoutput>

    <tr>
      <td>#results.reportID#</td>
            <td>#results.county#</td>
            <td>#results.product#</td>
           <!---' <td>#description#</td>--->
           </tr>
             <tr >
             <td bgcolor="##FFFFCC" colspan="3"><strong>Description:</strong> #results.description#</td></tr></cfoutput>
     
      </table>

    Inspiring
    May 13, 2009

    To avoid any confusion, I allways use the store name before any variable calls.

    In your example, when outputting the query use "results.ID" stead of just "ID".(goes for all used query columns)

    In this case CF cannot assume it should come from the VARIABLES store.

    Cheers,

    Bert.

    Michael Borbor
    Inspiring
    May 12, 2009

    I don't see where you set the var ID.