Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Define maximum colums / Next and Previous

Posted on 2003-11-08
5
Medium Priority
?
162 Views
Last Modified: 2013-12-24
I have a profile page that I'm building. Column output for thumbnails is preferred but I am not clear on how to define a maximum number of colums to display.. and then to place previous and next links. I would like 3 colums, then a maximum of 15 recors per page (5 rows)

Here is what I have so far.......

<cfquery name="getData" datasource="profile">
    SELECT *
    FROM contacts
      WHERE state='CA' and country='USA' and status='APPROVED'
                  ORDER BY RND(ContactID)
</cfquery>

<cfscript>
      if (NOT structKeyExists(form, 'cols')) form.cols = 3;
</cfscript>

<cfif getData.recordCount MOD form.cols>
      <cfset variables.rows = int(getData.recordCount/form.cols) + 1>
      <cfset variables.pads = form.cols - (getData.recordCount MOD form.cols)>

      <cfloop from="1" to="#variables.pads#" index="i">
            <cfset temp = queryAddRow(getData)>
            <cfset temp = querySetCell(getData, 'contactID', '')>
      </cfloop>
<cfelse>
      <cfset variables.rows = getData.recordCount/form.cols>
</cfif>

<cfset variables.thisRow = 1>
<cfset variables.newrow = false>

<CFINCLUDE TEMPLATE="uppertemplate.cfm">
<p align="center"><b><font face="Arial" color="FFFFFF">CALIFORNIA, UNITED STATES LISTINGS</font></b></p>
<table style="border:0px" cellpadding="0" width="100%">
<tr>
<cfoutput query="getData">
      <cfif variables.newrow IS true><tr></cfif>
          <td><p align="center"><img border="0" src="../listphotos/#contactID#a.gif"></td>
      <cfif (getData.currentRow MOD form.cols EQ 0) AND (variables.thisRow LT variables.rows)>
            </tr>
            <cfset variables.newrow = true>
            <cfset variables.thisRow = variables.thisRow + 1>
      <cfelse>
            <cfset variables.newrow = false>
      </cfif>
</cfoutput>
</tr>
</table>

<CFINCLUDE TEMPLATE="lowertemplate.cfm">
0
Comment
Question by:TallGuyMD
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:Mause
ID: 9707284
Hi there

Just tried to build one for you. try this:

<cfquery name="getData" datasource="profile">
    SELECT *
    FROM contacts
     WHERE state='CA' and country='USA' and status='APPROVED'
               ORDER BY RND(ContactID)
</cfquery>

<cfparam name="maxTD" default="3">
<cfparam name="maxTR" default="5">
<cfparam name="startrow" default="1">
<cfset name="maxrows" default=maxTD * maxtr>

<CFINCLUDE TEMPLATE="uppertemplate.cfm">

<p align="center"><b><font face="Arial" color="FFFFFF">CALIFORNIA, UNITED STATES LISTINGS</font></b></p>
<table style="border:0px" cellpadding="0" width="100%">
<tr>
<cfoutput query="getData" startrow="#startrow#" maxrows="#maxrows#">
    <td><p align="center"><img border="0" src="../listphotos/#contactID#a.gif"></td>
    <cfif not (getdata.currentrow mod maxTD) AND (getdata.currentrow-startrow) is not (maxrows-1)></tr><tr></cfif>
</cfoutput>
</tr>
</table>

<cfset previousstart = startrow - maxrows>
<cfif previousstart GTE 1>
<a href="thiesfile.cfm?startrow=#previousstart#">PREVIOUS</a>
</cfif>

<cfset nextstart = startrow + maxrows>
<cfif nextstart LT getData.recordcount>
<a href="thiesfile.cfm?startrow=#nextstart#">NEXT</a>
</cfif>

<CFINCLUDE TEMPLATE="lowertemplate.cfm">


Let me know if this works for you
Mause
0
 

Author Comment

by:TallGuyMD
ID: 9707402
Thanks for the reply Mause.. But that generates an error.

Invalid CFML construct found on line 11 at column 23.  
ColdFusion was looking at the following text:
default

The CFML compiler was processing:

a cfset tag beginning on line 11, column 2.
 
 
The error occurred in line 11
 
9 : <cfparam name="maxTR" default="5">
10 : <cfparam name="startrow" default="1">
11 : <cfset name="maxrows" default=maxTD * maxtr>
12 :
13 : <CFINCLUDE TEMPLATE="uppertemplate.cfm">
 
0
 
LVL 10

Accepted Solution

by:
Mause earned 500 total points
ID: 9707435
hhhmmm sorry my fould

replace line 11 width:
<cfset maxrows=maxTD * maxtr>

Mause
0
 

Author Comment

by:TallGuyMD
ID: 9707472
Yes... that worked just fine. Thanks a bunch :)
0
 
LVL 10

Expert Comment

by:Mause
ID: 9707714
NP, glad I could help

Mause
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

618 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