Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Rows and Columns

0 views
Skip to first unread message

jazz823

unread,
Feb 3, 2006, 10:06:11 AM2/3/06
to
I have a page that displays inventory. I want to set the maxrows to 3 and the
columns to 3. I am close but for some reason, each page has only one row and
the same products. I am attaching the code as I am sure I have just looked at
this too long. thanks in advance, essentially it should display 9 products at
a time 3 across and 3 down and then page numbers at the bottom.

<table cellpadding="0" cellspacing="0" width="100%"
background="images/bodybg.jpg"><TR><td valign="top">
<table cellpadding="0" cellspacing="0" bgcolor="white" width="775"><TR><TD
width="10"></td><td valign="top">


<table cellpadding="10" cellspacing="10" width="500"><TR>
<TD width="50"></td>
<td> <cfquery name="getprojects" datasource="#application.ds#">
select * from cartitems
where productcategory = #url.cid# and 1=1
</cfquery>
<cfquery name="gettitle" datasource="#application.ds#">
Select * from productcategory
where categoryid = #url.cid#
</cfquery>
<table><tr><td width="100"></td>
<TD width="485" valign="top">
<br>

<table width="400" cellspacing="0" cellpadding="0">
<tr><cfoutput>
<td><FONT SIZE="2" color="gray" face="arial"><B>Category:
</B>#gettitle.category#</FONT></td>
</cfoutput></tr>
</table>
<BR> <!-- PAGE CONTENT GOES HERE --><cfif
#getprojects.recordcount# eq 0>
<font face="verdana, Arial," size="1"> (There are no pictures posted right
now.)<BR><BR><BR><BR></font>
</cfif>
<cfoutput>
<table cellpadding="0" cellspacing="0">
<tr>
<td><font face="Arial, Helvetica, sans-serif" size="3"><b></b></font>
<cfif getprojects.recordcount gt 0>
<cfset numcols = 3><!--- can be set to anything, except one --->
<cfset widthpercent = 100>
<cfset colwidth = int(widthpercent / numcols)>
<cfset tablewidth = colwidth * numcols>
<table border="0" width="#tablewidth#">


<cfset maxrows = 3>
<cfif #IsDefined("url.start")#>
<cfset start = #url.start#>
<cfelse>
<cfset start = 1>
</cfif>
<cfif #IsDefined("url.k")#>
<cfset k = #url.k#>
<cfelse>
<cfset k = #start#>
</cfif>

<cfloop index = "k" from=1 to=#MaxRows#>
<cfif (k LTE getprojects.RecordCount)>

<cfset crow = k mod numcols>
<cfif crow eq 1>
<tr>
<td width="#colwidth#%" align="left" valign="top">

<font face="arial" size="1"><font color="maroon">
</FONT></FONT>
<table border="0" width="250" cellpadding="4" cellspacing="4"><tr><td><font
face="arial" size="1"><font color="maroon"><cfif
#getprojects.productimagess[k]# neq "">
<a href="projectdetail.cfm?pid=#getprojects.productid[k]#" class='blacktext'
onMouseOver="this.className ='redtext'" onMouseOut="this.className='blacktext'"
>
<img
src="http://www.agenity.com/sitemanager/uploads/product/#client.id#/#getprojects
.productimagess[k]#" border="0" width="110"></a></cfif><BR>
</FONT>&nbsp;</FONT></td><td valign="top" width="175"><a
href="projectdetail.cfm?pid=#getprojects.productid[k]#" class='blacktext'
onMouseOver="this.className ='redtext'" onMouseOut="this.className='blacktext'"
><font size="2" face="arial" color="676767"><b><font
size="2">#getprojects.productname[k]#</font></b></font></a><br>
<hr>
<font size="1" face="arial"
color="676767">#dollarformat(getprojects.price[k])#&nbsp;Each<br>Min QTY:
#getprojects.minqty[k]#</font>
</td></tr></table></td><cfelseif crow eq 0>
<td width="#colwidth#%" align="left" valign="top">
<font face="arial" size="1"><font color="maroon">
</FONT></FONT>
<table border="0" width="250" cellpadding="4" cellspacing="4"><tr><td><font
face="arial" size="1"><font color="maroon"><cfif
#getprojects.productimagess[k]# neq "">
<a href="projectdetail.cfm?pid=#getprojects.productid[k]#" class='blacktext'
onMouseOver="this.className ='redtext'" onMouseOut="this.className='blacktext'"
>
<img
src="http://www.agenity.com/sitemanager/uploads/product/#client.id#/#getprojects
.productimagess[k]#" width="110" border="0"></a></cfif><BR>
</FONT>&nbsp;</FONT></td><td valign="top" width="175"><a
href="projectdetail.cfm?pid=#getprojects.productid[k]#" class='blacktext'
onMouseOver="this.className ='redtext'" onMouseOut="this.className='blacktext'"
><font size="2" face="arial" color="676767"><b><font
size="2">#getprojects.productname[k]#</font></b></font></a><br>
<hr>
<font size="1" face="arial"
color="676767">#dollarformat(getprojects.price[k])#&nbsp;Each<br>Min QTY:
#getprojects.minqty[k]#</font>
</td></tr></table></td></tr>
<cfelse>
<td width="#colwidth#%" align="left" valign="top">

<font face="arial" size="1"><font color="maroon">
</FONT></FONT>
<table border="0" width="250" cellpadding="4" cellspacing="4"><tr><td><font
face="arial" size="1"><font color="maroon"><cfif
#getprojects.productimagess[k]# neq "">
<a href="projectdetail.cfm?pid=#getprojects.productid[k]#" class='blacktext'
onMouseOver="this.className ='redtext'" onMouseOut="this.className='blacktext'"
>
<img
src="http://www.agenity.com/sitemanager/uploads/product/#client.id#/#getprojects
.productimagess[k]#" border="0" width="110"></a></cfif><BR>
</FONT>&nbsp;</FONT></td><td valign="top" width="175"><a
href="projectdetail.cfm?pid=#getprojects.productid[k]#" class='blacktext'
onMouseOver="this.className ='redtext'" onMouseOut="this.className='blacktext'"
><font size="2" face="arial" color="676767"><b><font
size="2">#getprojects.productname[k]#</font></b></font></a><br>
<hr>
<font size="1" face="arial"
color="676767">#dollarformat(getprojects.price[k])#&nbsp;Each<br>Min QTY:
#getprojects.minqty[k]#</font>
</td></tr></table></td></cfif>
<cfelseif (k GT getprojects.RecordCount)>
<cfset k = k + 1>
</cfif> </cfloop>
</table></cfif></tr>
</table><table align="left" cellspacing="0" width="98%">
<tr>
<cfset last = getprojects.RecordCount>
<cfset previous = Start - MaxRows>
<cfset next = Start + MaxRows>
<cfset final = next-1>
<cfif (final GT getprojects.RecordCount)>
<cfset final = getprojects.RecordCount>
</cfif>
<cfif (#Start# GT 1) AND (#Start# LT #getprojects.RecordCount#)>

</cfif>
<td align="CENTER" height="2"> Items #start#
through #final# of #getprojects.RecordCount# <br>
<cfset NumPages = Ceiling(getprojects.RecordCount/maxrows)>
<cfparam name="PageNum" default="1">
<cfset NextPage = PageNum+1>
<cfset PrevPage = PageNum-1>
<br>
<font face="verdana" size="2"><b>Jump to page<br>
</b></font> <cfif (#Start# GT 1) AND (#Start# LT
#getprojects.RecordCount#)>
<a href="projectresults.cfm?k=#previous#&start=#previous#&cid=#url.cid#">
<font face="verdana" size="2"><b>Previous</b></font></a>
<cfelse>

</cfif>
<cfloop index="ThisPage" from="1" to="#NumPages#">

<cfif ThisPage IS PageNum>
<font face="verdana" size="2"><b>#ThisPage#&nbsp;</b></font>
<cfelse>
<cfset PageNumStart = (((ThisPage - 1) * maxrows) + 1)>
<a
href="#CGI.SCRIPT_NAME#?k=#PageNumStart#&start=#PageNumStart#&PageNum=#ThisPage#
&cid=#url.cid#">
<font face="verdana" size="2"><b>#ThisPage#</b></font></a>&nbsp;
</cfif>

</cfloop>
<cfif (#Start# LT #getprojects.RecordCount#) AND (#next# LT
#getprojects.RecordCount#)>
<a href="projectresults.cfm?k=#next#&start=#next#&cid=#url.cid#">
<cfelse></a>
<a href="projectresults.cfm?k=#next#&start=#next#&cid=#url.cid#">
<font face="verdana" size="2"><b>Next</b></font></a>>>
</cfif>

<cfset loopcount = #Ceiling(getprojects.RecordCount / MaxRows)#>
</td><cfif (#Start# LT #getprojects.RecordCount#) AND (#next# LT
#getprojects.RecordCount#)>

<cfelse>
</cfif>
</tr>
<tr>
<td align="CENTER" height="2"><font face="verdana" size="1"><a
href="products.cfm">Click
here</a> to see our complete list of inventory.</font>
<br>
</td></tr>
</table></cfoutput> </td>
</tr></table>


</td>
</tr></table>

</td><td align="right" background="images/edge.jpg" width="5"
height="200"></td></tr></table>
</td>
</tr></table>
<cfinclude template="footer.cfm">
</body>
</html>

Dan Bracuk

unread,
Feb 3, 2006, 10:25:06 AM2/3/06
to
You have way too much code. I have the following general suggestions for
making it easier to read and understand.

1. To the maximum extent possible, separate your logic from your display.
You are running queries inside table tags.

2. Only code what is necessary. Your first table doesn't appear to display
anything.

jazz823

unread,
Feb 3, 2006, 10:37:45 AM2/3/06
to
this is essentially the piece i am stuck with.

The rest I should have left out. Apologies.

Dan Bracuk

unread,
Feb 3, 2006, 11:28:47 AM2/3/06
to
It might be simpler if you cached your queries and used the startrow and maxrows attributes of the cfoutput tags instead of all that iffing and looping.

jazz823

unread,
Feb 3, 2006, 1:26:29 PM2/3/06
to
Thanks, i will give it a shot.
0 new messages