Click to See Complete Forum and Search --> : check date display text


daveo1
10-24-2003, 11:04 AM
I am looking for a script that checks the current date and then displays text depending on the date. Basically I want to be able to display a different line of text each day on a web page automatically. Does this make sense to any one and can any one help? I am using ASP pages and a Access database. Figured I could set up a table inthe database specific to this but dont know how I would go about checking the date and displaying....

thanks

simflex
10-24-2003, 11:46 AM
Let me make sure that I understand you.
You are interested in displaying text on a daily basis.
This means your database will contain at least 2 fields:
textToBeDisplayed text
CurrentDate datetime --the value of this will be preset to todays date



then I would say:
<%
curDate = date()
sql = "SELECT textToBeDisplayed FROM YourTable
WHERE currentDate = #"curDate"#"
%>
So that everyday when you enter data, it will contain the days date and your query will do same.
If I misunderstood you, please advise

daveo1
10-24-2003, 12:18 PM
well...

this is the deal...

my web page there is a button that when clicked it brings up the joke of the day. currently i have tyo change the joke manually every day. so i dont want to do this any more.

So, I have a list of jokes plan to create a table with all the jokes in one column and not sure where to go with this ...

I need to be able to check change the joke day to day automatically.

Now you get it?


-d

simflex
10-24-2003, 01:06 PM
in that case, you will need to do 2 things:
one, you still need a database with 3 fields:
JokeID an auto number,
Jokes text,
JokeDate dateTime.
This way, you enter joke, and the date of joke.
So the data will look like this:

ID Jokes DATE
1 hi 10/24/2003
2 hello 10/25/2003
3 mynext joke 10/26/2003

You will then write your asp code to pull the dates in.

Dim strSQL1
strSQL1 = "SELECT * FROM JOKES ORDER BY jokeDate;"
rsJokes.Open strSQL1, objConn
QuoteCount = 0
While Not rsJokes.EOF
JokeCount = JokeCount + 1
rsJokes.MoveNext
Wend
rsJokes.MoveFirst


<HTML>
<HEAD>
<TITLE>Joke of the day</TITLE>
<LINK REL="STYLESHEET" TYPE="text/css" HREF="style.css">
</HEAD>
<BODY>
<TABLE WIDTH="75%">
<%
' Here we are doing a loop and writing out the Jokes until
' we reach the end of the recordset and we reach the max
' of the amount of texts we specified per page
Count = 0
Do While Not rsJokes.EOF
Response.Write "<TR>" & _
"<TD><H4>" & rsJokes("Date") & "</H4></TD>" & _
"</TR><TR>" & _
"<TD>" & rsJokes("Text") & "</TD></TR>" & _
</TR>"
Count = Count + 1
rsJokes.MoveNext
Loop
%>
</TABLE>

Of course I am at work and don't have time to test but this should give you a nice idea of what is going on.
You need to come up with connectionstring to db.