Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving only the last 400 chars from recordset

Status
Not open for further replies.

dreamaz

Technical User
Dec 18, 2002
184
0
0
CA
Hello,

I have a fulltext field of over 10K chars. I am building a summary page to retrieve all the fields. I would like only the last 400 (or less) chars of this particular field displayed.

To make it a bit more complex, this field has multiple lines with spaces, some lines start with dates (when the record was last update) and i would like the next available date shown so i don't get data that is displayed to start mid-sentence.

Hope this is clear.

Thanks for your help
 
The substr function should work, by doing at first substr($texto,-400) and next doing a while loop and decrementing in one until you find a whitespace.
 
You got me at the 'decrementing in one until you find a whitespace'

Currently the code is

<?php echo nl2br ($row_GetProject['Details']); ?>

I'm guessing you suggest <?php echo substr($row_GetProject['Details'], -400); ?>
 
Yeah, texto would be $row_GetProject['Details']

And by the decreasement I mean the following

At first you have $variable=substr($row_GetProject['Details'],-400);

You check $variable first char and check if it is a whitespace or whatever symbol you are separating your info.

If it is not you go backwards in the text: I mean $variable=substr($row_GetProject['Details'],-401);... $variable=substr($row_GetProject['Details'],-402) until you find what you are using as separator.
 
It may be easier to find the last space in your 400 character string by using strrpos

If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top