2 Replies - 6938 Views - Last Post: 18 February 2011 - 11:51 AM Rate Topic: -----

#1 epidemik  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 14-June 08

Getting the years that contain post for that year

Posted 17 February 2011 - 04:42 PM

I am querying the years that is posted. The issue that I am having or the goal that I am trying to accomplish is getting the year to only appear once instead of multiple times. The way I dreamed to have it function is that it would list the year if it has any post associated with that year. Any sugestions or tutorials or examples that I can use to accomplish this task.

right now all the post are posted with the year 2011, so now for each post it post 2011 under the navigation bar.

Hopefully everything stated is clear.

<cfquery name="years" datasource="#dsn#">
SELECT year_posted, featured_posted
FROM Featured_artist
GROUP BY year_posted
ORDER BY year_posted DESC

</cfquery>
<center>
<cfoutput query="years">
<a href="feat_archived.cfm?yr=#DateFormat(featured_posted,'yyyy')#">#DateFormat(featured_posted,'yyyy')#</a> <br />
</cfoutput>
</center>




the output show multiple year 2011 in stead of one.

I would like for it to be listed from the most recent year as below:

2013
2012
2011

Is This A Good Question/Topic? 0
  • +

Replies To: Getting the years that contain post for that year

#2 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1948
  • View blog
  • Posts: 3,488
  • Joined: 13-January 08

Re: Getting the years that contain post for that year

Posted 18 February 2011 - 06:26 AM

View Postepidemik, on 17 February 2011 - 06:42 PM, said:

I am querying the years that is posted. The issue that I am having or the goal that I am trying to accomplish is getting the year to only appear once instead of multiple times. The way I dreamed to have it function is that it would list the year if it has any post associated with that year. Any sugestions or tutorials or examples that I can use to accomplish this task.

right now all the post are posted with the year 2011, so now for each post it post 2011 under the navigation bar.

Hopefully everything stated is clear.

<cfquery name="years" datasource="#dsn#">
SELECT year_posted, featured_posted
FROM Featured_artist
GROUP BY year_posted
ORDER BY year_posted DESC

</cfquery>
<center>
<cfoutput query="years">
<a href="feat_archived.cfm?yr=#DateFormat(featured_posted,'yyyy')#">#DateFormat(featured_posted,'yyyy')#</a> <br />
</cfoutput>
</center>




the output show multiple year 2011 in stead of one.

I would like for it to be listed from the most recent year as below:

2013
2012
2011



<cfquery name="years" datasource="#dsn#">
SELECT year_posted, featured_posted
FROM Featured_artist
GROUP BY year_posted
ORDER BY year_posted DESC
</cfquery>

<cfquery name="dYears" dbtype="query">
SELECT DISTINCT featured_posted
FROM years
ORDER BY featured_posted DESC
</cfquery>

<center>
<cfoutput query="dYears">
<a href="feat_archived.cfm?yr=#DateFormat(featured_posted,'yyyy')#">#DateFormat(featured_posted,'yyyy')#</a> <br />
</cfoutput>
</center>



Try that and see how that works for you.
Was This Post Helpful? 1
  • +
  • -

#3 epidemik  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 49
  • Joined: 14-June 08

Re: Getting the years that contain post for that year

Posted 18 February 2011 - 11:51 AM

View PostCraig328, on 18 February 2011 - 06:26 AM, said:

View Postepidemik, on 17 February 2011 - 06:42 PM, said:

I am querying the years that is posted. The issue that I am having or the goal that I am trying to accomplish is getting the year to only appear once instead of multiple times. The way I dreamed to have it function is that it would list the year if it has any post associated with that year. Any sugestions or tutorials or examples that I can use to accomplish this task.

right now all the post are posted with the year 2011, so now for each post it post 2011 under the navigation bar.

Hopefully everything stated is clear.

<cfquery name="years" datasource="#dsn#">
SELECT year_posted, featured_posted
FROM Featured_artist
GROUP BY year_posted
ORDER BY year_posted DESC

</cfquery>
<center>
<cfoutput query="years">
<a href="feat_archived.cfm?yr=#DateFormat(featured_posted,'yyyy')#">#DateFormat(featured_posted,'yyyy')#</a> <br />
</cfoutput>
</center>




the output show multiple year 2011 in stead of one.

I would like for it to be listed from the most recent year as below:

2013
2012
2011



<cfquery name="years" datasource="#dsn#">
SELECT year_posted, featured_posted
FROM Featured_artist
GROUP BY year_posted
ORDER BY year_posted DESC
</cfquery>

<cfquery name="dYears" dbtype="query">
SELECT DISTINCT featured_posted
FROM years
ORDER BY featured_posted DESC
</cfquery>

<center>
<cfoutput query="dYears">
<a href="feat_archived.cfm?yr=#DateFormat(featured_posted,'yyyy')#">#DateFormat(featured_posted,'yyyy')#</a> <br />
</cfoutput>
</center>



Try that and see how that works for you.



thanks it worked perfectly
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1