Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 21st, 2004, 09:36 AM
chabuhi chabuhi is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 89 chabuhi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 7 h 55 m 54 sec
Reputation Power: 5
Truncating overlong text from a db field

I've got a site that I inherited and I'm having trouble getting an index to display text from a db the way I want it to. Basically, the index is a list of records from the db, and the fields displayed are "date", "record no.", "contact", "summary", etc. I've modified it so that if a "followup" exists or if the "summary" field is null in the db, then the "followup" data is displayed instead. This function works as desired, however I cannot seem to get the text to truncate the way I'd like (and since I'm basically hacking a file I didn't create, I have no idea if I'm in the right place, or if I can even provide the necessary info here to help you help me).

I want the text in the field to be truncated to 80 characters if it is greater than that. This works if it's the "summary" data that is displayed, but doesn't work if the "followup" text is displayed instead. This is the original code ("GetFollowup" is an include that parses the text from the "followup" field in the database if there is any):

'shortSummary = Trim(GetFollowup(conn, rs(0)))
'if shortSummary = "" then
'shortSummary = rs(7)
'end if
'if len(shortSummary) > 80 then
'shortSummary = Left(rs(7), 80) & " ..."
'end if

This calls GetFollowup which queries the db to see if there is any followup data available. If so, the followup is displayed instead of the summary. If not, then the summary is displayed as normal. If the summary is > 80 chars it is truncated to 80 chars. Now for the unintended part: If a followup exists and is <=80 chars, then it displays just fine. However, if the followup is > 80 chars, then the summary is displayed. In other words, the code truncates the summary text just fine, however it does not truncate the followup text. If I change the code to: 'if len(shortSummary) > 1000 then ... then the followup displays fine (provided it doesn't exceed 1000 characters, hehe).

I'm attempting now to have the followup text truncated in the GetFollowup file, but since this is used elsewhere to pull the entire followup, that's kind of working backwards to me.

Any help is appreciated. I'm a complete beginner with this stuff -- learning it by poking around the files and breaking stuff.

Reply With Quote
  #2  
Old July 21st, 2004, 10:51 AM
chabuhi chabuhi is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 89 chabuhi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 7 h 55 m 54 sec
Reputation Power: 5
Sorry - found the problem. The sixth line refers back to the original summary text. Changing "rs(7)" to "shortSummary" solved the problem.

Thanks anyway!

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > Truncating overlong text from a db field


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT