Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset Loop 1

Status
Not open for further replies.
Mar 10, 2005
63
US
Hello, I'm having a bit of issues. I'm running a query and then outputing it with the date and title. That part I have working. But sometimes there are more than one item per date and I would like to only list the date once instead of on each record. Here's an example:

05/01/06

-Todays News

04/27/06

-CEO Announcements
-Today's Schedule

04/26/06

- May is Fitness Month

Any help would be appreciated. Thanks.
 
I though I just posted info about this in a recent thread?

anyways:

use cfoutput with the group attribute.

<cfoutput query="whatever" group="datefield">
<h3>#datefield#</h3>
<cfoutput>
- #newstitle#<br/>
</cfoutput>
</cfoutput>

double check that your query is sorted by the date field, or you might have dates repeat.

Kevin
 
Thanks for replying imstillatwork. This doesn't seem to work correctly though. It stops after one record even though I know there should be more. I don't know if my query is incorrect or what. Any other ideas?
 
<cfoutput query="whatever" group="datefield">
<h3>#datefield#</h3>
<cfoutput>
- #newstitle#<br/>
</cfoutput>
</cfoutput>

Is correct, with adjustments for your field names of course

this would assum data like

datefield | newstitle
----------------------
5/4/06 | News Title 1
5/4/06 | News Title 2
5/3/06 | News 3
5/3/06 | News 4
5/2/06 | News 5

wich would output like

<h3>5/4/06</h3>
News Title 1<br/>
Mews Title 2<br/>
<h3>5/3/06</h3>
News 3<br/>
News 4<br/>
<h3>5/2/06</h3>
News 5


So make sure that your datefield is date only, not time also, or the time part would make each date different, and not group together.





Kevin
 
That's how I have it. Here's a sample without the group and date formatting:

{ts '2006-05-04 00:00:00'}
ODTA Meeting on 10 May
{ts '2006-05-04 00:00:00'}
Senior Leader Announcement
{ts '2006-05-04 00:00:00'}
101 Critical Days of Summer Campaign Safety Fair
{ts '2006-05-04 00:00:00'}
E-Clippings

Here it is with the group:

{ts '2006-05-04 00:00:00'}
ODTA Meeting on 10 May

The dates are the same. There is no time, but the group isn't working.
 
here's the Query and code:

<cfquery name="getDailyNews" datasource="ICBMPROD">
select * from daily_main
where view_date > to_date('#dateformat(DateDiff('d','1',now()))#','dd-mon-yy')
and active = 1
order by view_date desc, important desc
</cfquery>

<ul>
<cfoutput query="getDailyNews" group="view_date">
<li>
#view_date#
</li>
<li>
<a href="/updatecontent/bin/<cfif getDailyNews.html eq 0>daily<cfelse>html</cfif>/#file_location#" <cfif getDailyNews.html eq 1>target="_blank"</cfif>>
#link_name# </a>
</li>
</cfoutput>
</ul>
 
no, of course not, but people gots to eat, sleep, and other functions, and i was just helping out while you were gone ;-)

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top