Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

dynamic tr td issues

Posted on 2013-01-02
3
Medium Priority
?
215 Views
Last Modified: 2013-01-03
I am using the following query but the data is coming as:

123
45
678

Here is the below Code i am using

Seems to be OK, but not user what is the Problem:

<cfquery name="qryIA" dbtype="query">
SELECT DISTINCT patientid, sum(total) as total FROM 
    myquery
    group by patientid, total
</cfquery>

  <cfscript>
        if (NOT structKeyExists(form, 'cols')) form.cols = 3;
    </cfscript>
  <cfif qryIA.recordCount MOD form.cols>
    <cfset variables.rows = int(qryIA.recordCount/form.cols) + 1>
    <cfset variables.pads = form.cols - (qryIA.recordCount MOD form.cols)>
    <cfloop from="1" to="#variables.pads#" index="i">
    <cfset temp = queryAddRow(qryIA)>
    <cfset temp = querySetCell(qryIA, 'patientid', '0')>
    </cfloop>
    <cfelse>
    <cfset variables.rows = qryIA.recordCount/form.cols>
  </cfif>
  <cfset variables.thisRow = 1>
  <cfset variables.newrow = false>
  <cfset variables.currentRow = 0>
  <table align="center" border="0" width="100%">
    <tr>
    <cfoutput query="qryIA" group="patientid">
    <cfquery name="qryIA1" dbtype="query">
        SELECT DISTINCT patientid, sum(total) as total FROM
        qryIA
        where patientid = #qryIA.patientid#
        group by patientid, total
       </cfquery>
    <cfif variables.newrow IS true>
      <tr>
    </cfif>
    <td height="30" valign="middle" align="center" style="border:1px dotted ##8471AD;">
    #qryIA1.patientid#<br />
    </td>

    <cfif (qryIA.currentRow MOD form.cols EQ 0) AND (variables.thisROW LT variables.rows)>
      <tr>

      <cfset variables.newrow = true>
      <cfset variables.currentRow = variables.currentRow + 1>
      <cfelse>
      <cfset variables.newrow = false>
    </cfif>
    </cfoutput>
    </tr>

  </table>

Open in new window

0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 39

Expert Comment

by:gdemaria
ID: 38737366
I don't see why you need to query inside the loop, it does the same thing as your group-by.  Just add the other CFOUTPUT.

In any case, whether you put the child query back or not, this is the way I would loop your table cells and rows..

 <table align="center" border="0" width="100%">
   <tr>
   <cfoutput query="qryIA" group="patientid">
     <cfoutput>
      <cfif qryIA.currentRow gt 1 and (qryIA.currentRow MOD form.cols EQ 0)>
       </tr><tr>
      </cfif>
       <td height="30" valign="middle" align="center" style="border:1px dotted ##8471AD;">
        #qryIA.patientid#
       </td>
	 </cfoutput>
   </cfoutput>
 </tr>
</table>

Open in new window

0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 38737442
te query inside is required, so cannot change, so replacing ur code will solve or not?
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 2000 total points
ID: 38737664
I said that because I don't see that the inside query does anything.  It doesn't add anything that your outside query is not already doing - but maybe you have more to add to it.

But here it is with the query.. you don't need all that newrow code..

 <table align="center" border="0" width="100%">
   <tr>
   <cfoutput query="qryIA" group="patientid">
      <cfquery name="qryIA1" dbtype="query">
        SELECT DISTINCT patientid, sum(total) as total FROM
        qryIA
        where patientid = #qryIA.patientid#
        group by patientid, total
      </cfquery>
   
    <cfif qryIA.currentRow gt 1 and (qryIA.currentRow MOD form.cols EQ 0)>
      </tr><tr>
    </cfif>
       <td height="30" valign="middle" align="center" style="border:1px dotted ##8471AD;">
        #qryIA1.patientid#
       </td>
   </cfoutput>
 </tr>
</table>

Open in new window

0

Featured Post

DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

Question has a verified solution.

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

This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Suggested Courses

715 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