Copy link to clipboard
Copied
Hello,
I have about 500 images that I want to display in rows of 5. Currently, I only know how to display them in 1 vertical column like this:
<CFOUTPUT QUERY="List" GROUP="AuthorID">
<CFOUTPUT>
<TR>
<TD ALIGN="left" VALIGN="top" WIDTH="542" style="padding-left:2em;text-indent:-2em"><A HREF="#request.BaseURL#/book.cfm?-#URL_Title#-&BookID=#BookID#"><img src="#request.BaseURL#/images/#Image#" width="50"></A></TD>
</TR>
</CFOUTPUT>
</CFOUTPUT>
Thank you for your help!
<CFOUTPUT QUERY="List" GROUP="AuthorID">
<!--- You should have something here for author, since you're grouping by author --->
<TR>
<CFOUTPUT>
<TD ALIGN="left" VALIGN="top" WIDTH="542" style="padding-left:2em;text-indent:-2em">
<A HREF="#request.BaseURL#/book.cfm?-#URL_Title#-&BookID=#BookID#"><img src="#request.BaseURL#/images/#Image#" width="50"></A>
</TD><cfif List.currentrow % 5 eq 0 AND List.currentrow neq List.recordCount>
</tr>
<tr>
</cfif>
</CFOUT
...
OK, then you should be able to modify your ORDER BY clause in your SQL statement like so:
ORDER BY Inventory.Series_No, Authors.AuthorLastName, Authors.AuthorFirstName, Authors.Title
and reduce the number of CFOUTPUTs you have, since you're not grouping your output:
<table border="0" width="582" cellspacing="0" cellpadding="0" align="center">
<cfoutput query="List">
<tr>
<td align="center" valign="top" width="542" style="padding-left:2em;text-indent:-2em">
<a href="#request.BaseURL#/book.cfm?-
Actually, Dave's offering was pretty close to what you are looking for, except the opening TR needs to be before the CFOUTPUT and the closing TR should be after the /CFOUTPUT.
<table border="0" width="582" cellspacing="0" cellpadding="0" align="center">
<tr>
<cfoutput query="List">
<td align="center" valign="top" width="542" style="padding-left:2em;text-indent:-2em">
<a href="#request.BaseURL#/book.cfm?-#URL_Title#-&BookID=#BookID#"><img src="#request.BaseURL#/images/#Image#" width="75"><
...
Dave provided that for you.
SELECT TOP 100 table.column1, table.column2, table2.column1, table2.column2
FROM table LEFT OUTER JOIN table2 ON table2.column1 = table.column1
ORDER BY blah blah blah
Now, this will limit to just the first 100. If you are looking for something that does pagination, it gets a bit more complex.
HTH,
^ _ ^
UPDATE: I haven't worked with MS SQL for a long time, so I had to look it up. Here's a good tutorial on pagination in MS SQL..
CFPARAM is a way to define and set a value to a variable IF the variable does not already exist. If it does exist, nothing happens, the value does not change. It's akin to:
<cfif NOT StructKeyExists(variables,'thisVar')>
<cfset thisVar = "foo" />
</cfif>
HTH,
^ _ ^
To add to WolfShade's correct CFPARAM answer, you can also use CFPARAM as a way for testing a variable's existence before the rest of your code executes, rather than in the middle of your code. That's not what's happening in your example, because you're providing a default value for all of the parameters. But if you weren't, you could throw an error before your CFQUERY starts running, and that error would be easier for you and automated error handlers to understand.
Dave Watts, Eidolon LLC
If you're not actually using those variables in your code later on, you don't need them. If you are, you may need them.
Dave Watts, Eidolon LLC
Copy link to clipboard
Copied
If you're not actually using those variables in your code later on, you don't need them. If you are, you may need them.
Dave Watts, Eidolon LLC