Solved

Cold Fusion Query Output Problem!

Posted on 2011-02-17
15
309 Views
Last Modified: 2012-05-11
dear Experts,

i want my query after to records it should come in second TR you can see picture i attached  how i want  my query should show my records

<cfoutput query="getMoreRecords">
                  <cfif i EQ 3 or i EQ 1>
                  	<tr>
                   </cfif>

                       <td width="43%" class="Inner_FooterLinks">
                         <a href="##">Namiba's Sink Hole</a>
                        </td>

                  <cfif i EQ 2 >
                   	</tr>
		<cfset i = 1 >
                     <cfelse>
                    <cfset i = ++i >
                  </cfif>
 </cfoutput>

Open in new window

table-lookLike.jpg
0
Comment
Question by:onlyamir007
  • 7
  • 5
  • 3
15 Comments
 
LVL 19

Expert Comment

by:erikTsomik
ID: 34919730
can you try something like this
<cfset i = 0>
<cfoutput query="getMoreRecords">
<cfset i++>
<cfif i EQ 4 or i EQ 1>
        <tr>
</cfif>
      
            <td width="43%" class="Inner_FooterLinks">
            <a href="##">Namiba's Sink Hole</a>
         </td>
      
        <cfif i eq 4>
            </tr>
      </cfif>


           
 </cfoutput>


0
 
LVL 52

Expert Comment

by:_agx_
ID: 34920223
Since every link is the same , I'm not sure I understand the desired results.  But I'll take a guess ...


If you want to display the results in 3 columns, use MOD

<table>
<tr>
<cfoutput query="getMoreRecords">
	<td width="43%" class="Inner_FooterLinks">
    	<a href="##">#SomeColumn#</a>
	</td>
	<cfif currentRow mod 3 eq 0>
		</tr><tr>
	</cfif>
 </cfoutput>
</tr>
</table>

Open in new window

0
 
LVL 4

Author Comment

by:onlyamir007
ID: 34921044
dear Aqx,

after applying ur code output coming something like this u can see attached pic and please have a look HTML OUT Putt
<table width="74%" border="0" cellspacing="2" cellpadding="2">
                
				                 
             
              <tr>
 
	<td  class="Inner_FooterLinks">
    	<a href="innerPage.cfm?contentid=18">Need For Speed</a>
	</td>
	
 
	<td  class="Inner_FooterLinks">
    	<a href="innerPage.cfm?contentid=19">Ray Feeding</a>
	</td>
	
 
	<td  class="Inner_FooterLinks">
    	<a href="innerPage.cfm?contentid=20">Off-Roading with AD4x4.com</a>
	</td>
	
		</tr><tr>
	
 
</tr>  
                 <!--  -->
                 
                 
                 
                 
               </table>

Open in new window

table-lookLike.jpg
0
 
LVL 4

Author Comment

by:onlyamir007
ID: 34921105
dear erikTsomik:

please have a look when im running ur code this is HTML OUTPUT please have look output picture aswell
<table width="74%" border="0" cellspacing="2" cellpadding="2">
                
				                 
             
 
 
 
 
 
 
        <tr>
 
      
            <td width="43%" class="Inner_FooterLinks">
            <a href="#">Namiba's Sink Hole</a>
         </td>
      
        
 
 
            
 
 
 
      
            <td width="43%" class="Inner_FooterLinks">
            <a href="#">Namiba's Sink Hole</a>
         </td>
      
        
 
 
            
 
 
 
      
            <td width="43%" class="Inner_FooterLinks">
            <a href="#">Namiba's Sink Hole</a>
         </td>
      
        
 
 
            
 
 
 
                 <!--  -->
                 
                 
                 
                 
               </table>

Open in new window

table-lookLike.jpg
0
 
LVL 52

Expert Comment

by:_agx_
ID: 34921179
>> dear Aqx,  after applying ur code output coming something like this u can see attached pic

@onlyamir007

Ok, I see the image. But I still don't understand your goal.  

Can you explain how it's different from what you want? ie What is it doing wrong?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 34921244
All of the values in your original example are the same:  "Namiba's Sink Hole".   That makes it hard to understand what your'e trying to do.

Can you use different values like:

ie          
SomeColumn
===========
apple
orange
pear
grape
banana
kiwi

... THEN show how you want the output to look

Example:
row 1 |   apple    |   orange |    pear |
row 2 |   grape    |  banana |    kiwi  |

Open in new window


0
 
LVL 4

Author Comment

by:onlyamir007
ID: 34921432
Dear _agx_

what i want to do  you can see HTML Code
----------------------------------------------------------------------------------
<table width="33%" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td width="48%">Record 1</td>
    <td width="52%">Record 4</td>
  </tr>
  <tr>
    <td>Record 2</td>
    <td>Record 5</td>
  </tr>
</table>
<table width="33%" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td width="48%">Record 1</td>
    <td width="52%">Record 4</td>
  </tr>
  <tr>
    <td>Record 2</td>
    <td>Record 5</td>
  </tr>
</table>

Open in new window

0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 19

Expert Comment

by:erikTsomik
ID: 34921572
maybe you can order the query such a way so you would not have to change the code
0
 
LVL 4

Author Comment

by:onlyamir007
ID: 34921595
<table width="33%" border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td width="48%">Row 1</td>
    <td width="52%">Row 3</td>
  </tr>
  <tr>
    <td>Row 2</td>
    <td>Row 4</td>
  </tr>
</table> 

Open in new window

0
 
LVL 4

Author Comment

by:onlyamir007
ID: 34921614
this is not the case of ordering  the query this is just how can i show my records in 2nd col after 2nd row u can see HTML how i want to show my records
               
                 
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 34921635
you can do it this way. Usea queryNew  to create a static query in the needed order and then simply output
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 34921725
Oh, I see.  You want to display the values down - then across. That is a little more involved than MOD but doable.

... 
<cfset numOfCols = 2>
<cfset offset = ceiling( getMoreRecords.recordCount / numOfCols )>

<cfoutput>
<table>
<cfloop from="1" to="#offset#" index="col">
<cfset secondCol = col + offset>
<tr>
	<td>#getMoreRecords.SomeColumnName[col]#</td>
	<td><cfif secondCol lte getMoreRecords.recordCount>
			#getMoreRecords.SomeColumnName[secondCol]#
		</cfif>
	</td>
</tr>
</cfloop>
</table>
</cfoutput>

Open in new window

0
 
LVL 4

Author Comment

by:onlyamir007
ID: 34924920
ohh dear thank you very much it is working fine but only one problem when  records are exceeding 4 it should come other Colum for example
 
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>Record 1</td>
    <td>Record 3</td>
    <td>Record 5</td>
  </tr>
  <tr>
    <td>Record 2</td>
    <td>Record 4</td>
    <td>Record 6</td>
  </tr>
  </table>

Open in new window

0
 
LVL 4

Author Closing Comment

by:onlyamir007
ID: 34928249
Thanks
0
 
LVL 52

Expert Comment

by:_agx_
ID: 34928783
@onlyamir007 -

You keep changing the requirements. First it was 3 columns, then 2 (down and across) . Now it's seems like something very different.  Which is it?  ;-)

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Advice on what platform to use for a web app for AWS 3 94
Specific format 21 182
Does a Google search find images with the word being searched? 11 62
Adjust the position 3 49
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now