Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - displaying records by fortnight
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

displaying records by fortnight

 Post Reply Post Reply
Author
Nischint View Drop Down
Groupie
Groupie
Avatar

Joined: 26 August 2002
Location: India
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote Nischint Quote  Post ReplyReply Direct Link To This Post Topic: displaying records by fortnight
    Posted: 23 February 2003 at 2:18pm

Hi,

First off, it's been a long time since I visited the forum, and I'm glad to see that there are some very good changes. But the one thing that I don't think is right, is that older posts, from older forum versions, have been deleted. That's a lot of useful information for anyone trying to search for help. And obviously, it is easier to keep those posts, rather than answering the same questions again and again.

Anyways, I have a bit of a problem on an asp archive page I'm building. Currently, it displays the number of records I want to. But now, I'd like to work differently, by fortnight.

This is to be a page which contains a list of my articles. I post articles at least thrice a week. The older articles in the archive, I save as html files, and display them using plain html in the archive section. As a result, I'm taking up double the webspace for the same thing. Which is why I want to use just one asp page, and that database. Users should be able to post comments for the article, so there is a comments link at the end of every article.

If someone were to go to archive.asp, the first thing they should see, is:

Archive - view fortnightly archives

[ January 2003 ]
January 16 - January 31, 2003
January 01 - January 15, 2003


[ December 2002 ]
December 16 - December 31, 2002
December 01 - December 15, 2002

[ November 2002 ]
November 16 - November 30, 2002
November 01 - November 15, 2002


[ October 2002 ]
October 16 - October 31, 2002
October 01 - October 15, 2002

Thereby showing that there are records in the database from October 2002 to January 2003, and that the user can view fortnightly entries of any of the mentioned periods.

Once a user has clicked on a link, say October 16 - October 31, 2002, then the archive.asp page should display:

[ October 16 - October 31, 2002 ]
------------------------------------- (an hr tag)
October 16 record
------------------------------------- (an hr tag)
October 15 record
------------------------------------- (an hr tag)
October 14 record
------------------------------------- (an hr tag)
October 13 record
------------------------------------- (an hr tag)


And so on and so forth. Now, how do I do this? And what code goes on the page? My asp knowledge is kinda limited, so if you could actually post the code, it would be helpful.

Right now, I'm using this code to show records:

<%
dim cn, rs

set cn = server.createObject("ADODB.Connection")
set rs = server.CreateObject("ADODB.Recordset")

function makeDBConnection()

'set the file path to the database
dbPath="database.mdb"

err.clear
on error resume next
' connect to the database
cn="driver={Microsoft Access Driver (*.mdb)};"
cn=cn & "dbq=" & server.mappath(dbPath)

 if err then
  Response.Write("<h3>Error Trapped</h3> while creating DB connection<p>" & err.description)
  Response.End
 end if

end function

function makeRS(SQL)

'Create a recordset
 on error resume next
  rs.Open sql, CN

 if err then
  Response.Write("<p>Error Trapped<p>" & err.description & "<p>while reading from DB<p> " & SQL)
  Response.End
 end if

 makeRS=rs

end function
%>
<% makeDBConnection() %>
<%
dim dcDates, postdate

call showHeader()
call record
call showFooter()

sub record
' show the entry

' if no entry selected show the first five records
if not request("id")="" then
 sql="select * from articles where artid = " & request("id") & " order by postdate desc"
else
 sql="select top 5 * from articles order by postdate desc"
end if

' select records from database
makeRS(SQL)

' while not end of records ..
do while not rs.EOF

' read the title and text
strLabel=rs("strLabel")
strText=rs("strText")
artpostid=rs("artid")
%>
<hr />
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td><%=strLabel%></td></tr>
<tr><td><br /><%=strText%><br /></td></tr>
<tr><td><br /><a href="javascript:comments(<%=artpostid%>)">comments [<script type="text/javascript" src="comments.asp?artpostid=<%=artpostid%>&amp;count=1"></script>]</a><br /></td></tr>
</table>
<%

rs.movenext
' loop
loop
rs.close

end sub

sub showHeader
' show top of page
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>..my articles..</td>
</tr>
</table>
<%
end sub

sub showFooter
' show bottom of page
%>
<hr />
<%

Back to Top
Nischint View Drop Down
Groupie
Groupie
Avatar

Joined: 26 August 2002
Location: India
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote Nischint Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2003 at 5:48pm
What happened? Why is there no answer for this one? Don't tell me you guys are giving up???
Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2003 at 6:01pm

Its unlikely that someone will look through a heap of code to try and troubleshoot an error, especially when you didn't post what it was :=)

Perhaps get as far as you can, post the error and the relevant code and we might be able to help a little better.

Cheers,
Andrew

There have been many, many posts made throughout the world...
This was one of them.
Back to Top
skyworld View Drop Down
Senior Member
Senior Member


Joined: 12 December 2002
Location: United States
Status: Offline
Points: 134
Post Options Post Options   Thanks (0) Thanks(0)   Quote skyworld Quote  Post ReplyReply Direct Link To This Post Posted: 24 February 2003 at 6:37pm

we cant really help you because you did not say whats wrong and we dont have a copy of your database to see whats wrong . . . Try posting a error numbeR?

Back to Top
Nischint View Drop Down
Groupie
Groupie
Avatar

Joined: 26 August 2002
Location: India
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote Nischint Quote  Post ReplyReply Direct Link To This Post Posted: 25 February 2003 at 4:27am

Sorry, I thought I had posted everything necessary for the help I needed. But anyways, the deal is that I have an archive page that displays "x" number of records, as you can see from the code above". Now instead of that, I want the records to be displayed by fortnight, exactly like I have described in the post above.

My database has 4 columns, "artid" (the id number of the article), "strLabel" (my date format of day, date, year, eg Wednesday, 12th March, 12:00 am), "postdate" (the date itself, eg 12/03/2002) and "strText" (my article).

I'd like the asp page to sort records by fortnight, so that a user can view them.

Is this enough?

Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 25 February 2003 at 4:49am

OK, so what have you tried so far? What we're getting at is that no-one will write the code for you.

We are here to try and troubleshoot the errors you are getting AFTER you try it yourself. You'll find it difficult to learn anything otherwise.

Its pretty easy for someone to come here and say: "This is how I want something to look - write the code for me please"

So anyway, you're half way there already, you've worked out how you want it to look - now work backwards from that. Ask yourself questions:

  • How would I determine if there are records for a certain fortnight/month?
  • What type of query would I need to filter the records by date?
  • What information would I have to pass from the first page to the next (in the querystring) so as to tell the next page which dates to display?

Try these for a start and tell us how you go.

Cheers,
Andrew

There have been many, many posts made throughout the world...
This was one of them.
Back to Top
Nischint View Drop Down
Groupie
Groupie
Avatar

Joined: 26 August 2002
Location: India
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote Nischint Quote  Post ReplyReply Direct Link To This Post Posted: 26 February 2003 at 3:52pm

Okay, you may not know this, but I have absolutely little or no knowledge of ASP and coding. I do know how to write HTML though, and more specifically XHTML. The reason I posted this question here was to in fact get the code. Whatever asp apps I do use, are from scripts that I have downloaded off the net. In fact, the only asp script I do use is when I write my articles. Once they are written in a textbox on my page, I save it as a record, and it gets displayed to the user.

Now I'd like to have an archive of it. And I do not know how to do this in ASP. The code that I sent above is the one that I use to show my articles, but it shows only the number mentioned there, that is 5 articles. I want an archive asp section too.

I just needed the code, but it seems like no one here can and/or is willing to help. Or is there?

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.