• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Displaying images in rows of 5

New Here ,
Jan 23, 2020 Jan 23, 2020

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!

TOPICS
Builder

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 7 Correct answers

LEGEND , Jan 23, 2020 Jan 23, 2020

 

<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
...

Votes

Translate

Translate
Community Expert , Jan 27, 2020 Jan 27, 2020

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?-

...

Votes

Translate

Translate
LEGEND , Jan 27, 2020 Jan 27, 2020

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"><
...

Votes

Translate

Translate
LEGEND , Jan 28, 2020 Jan 28, 2020

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..

Votes

Translate

Translate
LEGEND , Feb 06, 2020 Feb 06, 2020

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,

 

^ _ ^

Votes

Translate

Translate
Community Expert , Feb 06, 2020 Feb 06, 2020

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

Votes

Translate

Translate
Community Expert , Feb 07, 2020 Feb 07, 2020

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

Votes

Translate

Translate
Community Expert ,
Feb 07, 2020 Feb 07, 2020

Copy link to clipboard

Copied

LATEST

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

Dave Watts, Eidolon LLC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation