?
Solved

Coldfusion 8

Posted on 2009-04-19
2
Medium Priority
?
169 Views
Last Modified: 2013-12-24
Hi, I'm having an issue (lack of knowledge) trying to get Coldfusion to display the correct number of records.

It works fine when there are 4 records but inaccurately when there is less than 4. (Please see attached screen shots).

Any help would be be greatly appreciated.
<!---CFC Database Query starts--->
<cfinvoke 
 component="British_Forces_Foundation.BritishForcesFoundation.cfc.News"
 method="GetAllNewsInfo"
 returnvariable="qGetAllNewsInfo">
</cfinvoke>
<!---CFC Database Query Ends--->
 
<!---Pageable Record Sets Starts--->
<cfparam name="URL.startrow" default="1"/>
<cfset nNextStartRow = URL.startrow +4/>
<cfset nPreviousStartRow = URL.startrow -4/>
 
<cfset nEndRow  = URL.startrow +3/>
 
 
<!---Pageable Record Sets Ends--->
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>British Forces Foundation: Latest News from the BFF</title>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<style media="all" type="text/css">@import "css/all.css";</style>
	<script type="text/javascript" src="js/font-size.js"></script>
</head>
<body id="news_page">
<!-- page start -->
<div id="page" class="inner1">
  <h1 class="logo"><a href="index.cfm">BritishForcesFoundation</a></h1>
  <!-- content start -->
  <div id="content">
 
<!---col1 start--->
	<cfinclude template="includes/col-1.cfm">
<!---col1 end--->
 
<!-- col2 start -->
    <div id="col2">
      <div class="col2-top">
        <div class="col2-bottom inner-col2">
          <h2>Latest News from the BFF</h2>
        
<!---News Story Div Starts---> 
 
 
<cfoutput query="qGetAllNewsInfo" startrow="#URL.startrow#" maxrows="4">
 <!---Alt Row Code--->     
	<cfif qGetAllNewsInfo.CurrentRow mod 2 IS 1>
	<cfset class="fas-box fas">
    <cfelse>
    <cfset class="fas-box fas-light">
    </cfif>
<!--- Alt Row Code--->      
      
          <div class="#variables.class#">
            <div class="fas-corner">
              <div>
                <h3>#qGetAllNewsInfo.NewsHeadline#<br><span class="NewsInsertDate">#DateFormat(qGetAllNewsInfo.NewsInsertDate,"mmm, dd, yyyy")#</span></h3>
 
                <p>#qGetAllNewsInfo.NewsTextSmall#</p>
                <span class="more"><a href="news-full-story.cfm?NID=#qGetAllNewsInfo.NewsStoryID#">Click Here</a> for full story</span> </div>
              <img src="#qGetAllNewsInfo.NewsImageSmall#" alt="" /> </div>
          </div>
          
          
          
          
</cfoutput>
<!---News Story Div Ends---> 
 
          
          
<!---Record Count Starts--->           
	<cfoutput>
    <ul class="disp-menu">
            <li>Displaying #URL.startrow# - #nEndRow# of #qGetAllNewsInfo.Recordcount# articles </li>
<cfif nPreviousStartRow GTE 1>
            <li><a href="#CGI.SCRIPT_NAME#?startrow=#nPreviousStartRow#">Previous</a></li>
</cfif>
           <cfif nPreviousStartRow LT 1>
            <li><a href="#CGI.SCRIPT_NAME#?startrow=#nNextStartRow#">Next</a></li>
            </cfif>
            
	</ul>
	</cfoutput>
<!---Record Count Ends--->             
          
          
          
        </div>
      </div>
    </div>
 
 
    
 
<!-- col2 -->
<!---col3 start--->
	<cfinclude template="includes/col-3.cfm">
<!---col3 end--->
 
  </div>
  <!-- content end -->
  <!---header start--->
<cfinclude template="includes/header-navigation.cfm">
  <!--- header End--->
  
  <!---Footer start--->
	<cfinclude template="includes/footer-navigation.cfm">
<!--- Footer End--->
  
  
</div>
<!-- page end -->
</body>
</html>

Open in new window

Screen-Shots.pdf
0
Comment
Question by:greenchilli
2 Comments
 
LVL 27

Accepted Solution

by:
azadisaryev earned 2000 total points
ID: 24181879
change this:
<li>Displaying #URL.startrow# - #nEndRow# of #qGetAllNewsInfo.Recordcount# articles </li>

to:
<li>Displaying #URL.startrow# - #min(nEndRow, qGetAllNewsInfo.Recordcount)# of #qGetAllNewsInfo.Recordcount# articles </li>

Azadi
0
 

Author Closing Comment

by:greenchilli
ID: 31572058
Perfect!!,
Many thanks for your time and help.

Kind Regards,
Ashley
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question