TallGuyMD
asked on
Define maximum colums / Next and Previous
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/fo rm.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.c ols>
</cfif>
<cfset variables.thisRow = 1>
<cfset variables.newrow = false>
<CFINCLUDE TEMPLATE="uppertemplate.cf m">
<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/#contac tID#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.cf m">
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/fo
<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.c
</cfif>
<cfset variables.thisRow = 1>
<cfset variables.newrow = false>
<CFINCLUDE TEMPLATE="uppertemplate.cf
<p align="center"><b><font face="Arial" color="FFFFFF">CALIFORNIA,
<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/#contac
<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.cf
ASKER
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.cf m">
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.cf
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes... that worked just fine. Thanks a bunch :)
NP, glad I could help
Mause
Mause
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.cf
<p align="center"><b><font face="Arial" color="FFFFFF">CALIFORNIA,
<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/#contac
<cfif not (getdata.currentrow mod maxTD) AND (getdata.currentrow-startr
</cfoutput>
</tr>
</table>
<cfset previousstart = startrow - maxrows>
<cfif previousstart GTE 1>
<a href="thiesfile.cfm?startr
</cfif>
<cfset nextstart = startrow + maxrows>
<cfif nextstart LT getData.recordcount>
<a href="thiesfile.cfm?startr
</cfif>
<CFINCLUDE TEMPLATE="lowertemplate.cf
Let me know if this works for you
Mause