If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > RS Disply And ASP Formatting

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-30-03, 01:44
mossimo mossimo is offline
Registered User
 
Join Date: Nov 2003
Posts: 5
RS Disply And ASP Formatting

I have an article db that currently shows one article based on the most current Active date “CurrDate(Now)”
is my function to find the most current article. I would like to display the most current article for each “ArticleZone” in the db.

For example my asp page would look something like this:
<%=rsNews.Fields("ArticleZone=3")%><br>
<%=rsNews.Fields("ArticleZone=1")%> ect…


Table is named Articles and looks like this

ID, ArticleZone, ArticleActive, ArticleData
---------------------------------------------------------
1, 4, 11/25/2003, text/html content
2, 3, 10/24/2003, text/html content
3, 1, 12/22/2003, text/html content


SQL = "SELECT * FROM Articles WHERE ArticleActive <= " & CurrDate(Now) & " ORDER BY ArticleActive DESC"

I hope this is clear, Thanks mossimo
Reply With Quote
  #2 (permalink)  
Old 11-30-03, 22:21
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
Try the following:

select max(articlearchive),articlezone from articles group by articlezone
Reply With Quote
  #3 (permalink)  
Old 11-30-03, 22:23
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
How will select the most recent article if multiples exist for the same date and articlezone ?
Reply With Quote
  #4 (permalink)  
Old 12-26-03, 18:12
mossimo mossimo is offline
Registered User
 
Join Date: Nov 2003
Posts: 5
First post on a new board and I abandon it for a month.
What can I say there’s no internet in jail. Don’t worry I’m a bad guy
I just forgot to pay my taxes for a few decades so Uncle Sam wasn’t too happy.

Thanks rneale for the reply, you had asked:

How will select the most recent article if multiples exist for the same date and articlezone ?

Well the answer to both our questions was more than just a SQL Statement.
Here is the completed working script it’s pretty simple. I left out the include file that handles article selection,
its function “SQLDate(Now)” is called from the SQL Statement in the script and compares the current date with the each articles active date.


<!-- #include file="SQLDate.asp" -->
<%
Sub WriteZoneData(zone)

Select Case zone
Case 1
strZone = "zone1"
Case 2
strZone = "zone2"
Case 3
strZone = "zone3"
Case Else
strZone = ""
End Select

SQL = "SELECT * FROM Articles WHERE ActiveDate <= "&SQLDate(Now)&" _
& "AND ArticleZone = '"&strZone&"' ORDER BY ActiveDate DESC"

If strZone <> "" Then

OpenDB sconArticles
If Not Rs.EOF Then
Response.Write(Rs("ArticleName") And Rs("ArticleData"))
Else
Response.Write "No Articles Found"
End If
CloseDB
End Sub
%>

Disply the records
<%WriteZoneData(1)%>
<br>
<%WriteZoneData(2)%>
<br>
<%WriteZoneData(3)%>
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On