If I am pulling info from a db to write news and I want it to count the total number of words, trim it to 250, then print a link to that page how would i go about doing it? I can post the code if needed.
If Request.QueryString("page" = "" Then
iCurrentPage = 1
Else
iCurrentPage = CInt(Request.QueryString("page")
End If
strSQL = "SELECT dbo.News.Title, dbo.News.Author, dbo.News.DateWritten, dbo.News.TimeWritten, " &_
"dbo.News.Text FROM dbo.News ORDER BY dbo.News.id DESC"
Set Db = Server.CreateObject("ADODB.Connection"
Db.ConnectionTimeOut = Application("****_ConnectionTimeout"
Db.Open "Provider=****;User ID=****;Password=****;Initial Catalog=****;Data Source=****;", Application("****_RunTimeUserName", Application("****_RunTimePassword"
Set Rs = Server.CreateObject("ADODB.Recordset"
Rs.Open strSQL, Db, 1, 1
If Rs.BOF And Rs.EOF Then
Response.Write("No news? Either a DB problem or a quiet admin."
Else
If Not Rs.EOF Then
Rs.MoveFirst
Rs.PageSize = NumPerPage
iTotalPages = Rs.PageCount
Rs.AbsolutePage = iCurrentPage
End If
If Not iCurrentPage = 1 Then
Response.Write("<center><font size=""1""><a href=""" & strScriptName & "?page=" & iCurrentPage - 1 & """>Next " & NumPerPage & " posts</a> | "
Else
Response.Write("<center><font size=""1"">| "
End If
If Not iCurrentPage = iTotalPages Then
Response.Write("<a href=""" & strScriptName & "?page=" & iCurrentPage + 1 & """>Prev " & NumPerPage & " posts</a></font></center> <br />"
Else
Response.Write("</font></center><br />"
End If
Do While Not Rs.EOF And Count < Rs.PageSize
strTitle = Rs(0)
strTitle = Replace(strTitle, "%@%", "'"
If Not iCurrentPage = 1 Then
Response.Write("<center><font size=""1""><a href=""" & strScriptName & "?page=" & iCurrentPage - 1 & """>Next " & NumPerPage & " posts</a> | "
Else
Response.Write("<center><font size=""1"">| "
End If
If Not iCurrentPage = iTotalPages Then
Response.Write("<a href=""" & strScriptName & "?page=" & iCurrentPage + 1 & """>Prev " & NumPerPage & " posts</a></font></center><br />"
Else
Response.Write("</font></center><br />"
End If
End If
Rs.Close()
Db.Close()
Set Rs = Nothing
Set Db = Nothing
End Function
%>
I need to make that trim the text that it gets from the database to 250 characters, and write the name of the the post as the name of the html link to the full news posting.
For the total number of words you could count the number of spaces in the content and get a pretty good estimate.
-Tarwn ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.