Solved

How to show multiple records that have same date, under one date listing?

Posted on 2002-05-01
7
156 Views
Last Modified: 2013-12-24
Hi,

I need some help with the following:

I have a database table where I display records from the last 7 days in a CF page.

How can I display the date once for all records records that have the same date?
0
Comment
Question by:g118481
7 Comments
 
LVL 1

Expert Comment

by:FranzRinkleff
ID: 6984094
you could have some queries that gets the numbers of records for each day

for instance

<cfquery name="dateCountQuery" datasource="#datasource#">
 select * from my_table where date = '#theDate#'
</cfquery>
<cfset dateCount = dateCountQuery.RecordCount>

then in your table

<table>
<tr><th>Date></th><th>Other</th></tr>
<cfoutput query="otherQuery">
<tr>
  <td rowspan="dateCount">#otherQuery.daate#<td>


</cfoutput>
0
 
LVL 1

Expert Comment

by:FranzRinkleff
ID: 6984100
i prematurely submitted the previous message

you could have some queries that gets the numbers of records for each day

for instance

<cfquery name="dateCountQuery" datasource="#datasource#">
select * from my_table where date = '#theDate#'
</cfquery>
<cfset dateCount = dateCountQuery.RecordCount>

then in your table use the rowspan attribute of the td tag like this.  

otherQuery is your query for the last 7 days

<table>
<tr><th>Date></th><th>Other</th></tr>
<cfoutput query="otherQuery">
<tr>
 <td rowspan="dateCount">#otherQuery.date#<td>
  <td>#otherQuery.other#</td>
</tr>
</cfoutput>
</table>
0
 
LVL 1

Author Comment

by:g118481
ID: 6984432
I'm not sure you understand what I am trying to do here.  So, here is an example of what is needed:
Below are three sets of records from the table.  
each record has the same date, but only one has the date listed.

/***********************************************/
Tuesday April 30, 2002

10:00 AM - 12:00 PM EDT Scheduled
JAD 374364.Integrated Voice Access in CBSS.
DPSR NUMBER:
SPM ID:
SES LOE DUE DATE:
BRIDGE NUMBER/PASSCODE: 301-277-8057
LOCATION: Bridge
SES MANAGER: Greg Golombisky
SES PHONE NUMBER: 813-979-5813
PROGRAM MANAGER & PHONE NUMBER:
RELEASE INFO/COMMENTS: August
CREATE DATE: 2002-04-26 16:39:43
REVISION DATE: 2002-04-26 16:54:20

01:00 PM - 03:00 PM EST Scheduled
INSP 374816.0PDQ 585 $5 Minimum Spend Level
DPSR NUMBER: Not available
SPM ID: E1354A0
SES LOE DUE DATE:
BRIDGE NUMBER/PASSCODE: N/A
LOCATION: K401 Sabal
SES MANAGER: Janet Tomberlin
SES PHONE NUMBER: 813-979-5572
PROGRAM MANAGER & PHONE NUMBER:
RELEASE INFO/COMMENTS:
CREATE DATE:
REVISION DATE:

02:00 PM - 04:30 PM EDT Scheduled
JAD 374183.OMT PERMANENT NO TREAT/TEMPORARY NO TREAT
DPSR NUMBER:
SPM ID:
SES LOE DUE DATE:
BRIDGE NUMBER/PASSCODE: 813.273.6622, pc 9786137#
LOCATION: Tech Center - B201
SES MANAGER: Bob Coates
SES PHONE NUMBER: 813.978.6137
PROGRAM MANAGER & PHONE NUMBER:
RELEASE INFO/COMMENTS: October
CREATE DATE: 2002-04-03 12:53:53
REVISION DATE: 2002-04-18 11:55:44
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Accepted Solution

by:
FranzRinkleff earned 50 total points
ID: 6984458
i am not sure what you want either.


do you want the page to look like what you have displayed above.  Do you want the date to appear once,
Tuesday April 30, 2002, as shown above followed by the records for that date.

If so try something like this

<cfset tempDate = "">
--loop for records
<cfoutput query="theQuery">
-- following header appears only when the if statement true
<cfif theQuery.date neq tempDate>
  <cfset tempDate = theQuery.date>
  <h3>#tempDate#</h3>
</cfif>
--.... code for the rest of the records
</cfoutput>
0
 
LVL 1

Expert Comment

by:Agatheeswaran
ID: 6985367
Hi g118481,
First I will explain what i had understood from your question,

"Date" is also one of the column in the table, right!
if so, follow the code, its a straight forward solution,

select the records with date,
then in the cfm page code like this,
<tr>
<td>Date</td>
<td>Required column1</td>
.
.
<td>Required columnN</td>
</tr>
<cfset idate="">
<cfloop through the query>
   <tr>
   <cfif idate is not columndate>
     <cfset idate = columndate>
      <td>Date</td>
   <cfelse><td>&nbsp;</td>
   </cfif>
       <td>Required column1</td>
         .
         .
       <td>Required columnN</td>
    </tr>
</cfloop>

Basically, logic in it is first make the idate variable as null, then compare that idate with column date retrieved from the table, if there is no match then store that value in the variable and loop at the same time display it, or otherwise just put one space in that column.

Thanks
aga
0
 

Expert Comment

by:hop702
ID: 6991367
Could you use a group by in your query to group on the date?

Paul
0
 

Expert Comment

by:jriver12
ID: 7180303
g118481,

if you are still trying:

see if this is what you need.

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<CFQUERY NAME="testquery" DATASOURCE="dsn">
SELECT     PaymentDate, PaymentAmount, customerNumber
FROM         DenormalizePayments
WHERE     (PaymentDate BETWEEN '07/14/02' AND '07/24/02')
GROUP BY PaymentDate, PaymentAmount, customerNumber
ORDER BY PaymentDate
</CFQUERY>
<body bgcolor="#FFFFFF" text="#000000">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <cfoutput query="testquery"group="paymentdate">
    <tr><td>Date</td></tr>
     <tr>
      <td colspan="3"> #dateformat(paymentdate)#</td>
    <tr>
     <tr><td>CustomerNumber</td> <TD valign="top">Payment Amount</TD></tr>
      <td width="27%"> <cfoutput> #testquery.customernumber#<br>
        </cfoutput> </td>
         
      <td width="73%"><cfoutput>#dollarformat(testquery.PaymentAmount)#<br></cfoutput></td>
    </tr>
    <tr>
      <td colspan="2"></tr>
  </cfoutput>
</table>
</body>
</html>
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 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

23 Experts available now in Live!

Get 1:1 Help Now