Posted by Stefan Rybacki on 11/17/05 01:20
Stefan Rybacki wrote:
> Jonathan wrote:
>
>> I want to be able to take a description from a database, row called
>> {car_description} and cut it to a certain number of words and display
>> only that for the main gallery of cars before you click to get the full
>> description ... like many other sites do with the short description and
>> the "more" button next to it.. I can do the mroe button but how do I
>> right the rest of the tag..
>>
>> Assume I already have a db connection...so from inserting
>> into html template engine which gets crunched by php what would I do?
>> <?php xxxx.... ?>
>>
>
> Two possiblities:
>
>
> 1. use the database function LEFT to cut after a certain number of
> characters (maybe add '...' by using CONCAT if you want
> 2. use for example the php function substr() to cut the retrieved string.
I forgot since you mentioned you want to split by words not by character count, by the way
I would combine both, you should also search for the last word boundary within character 0
and max_character+1 and use this position for cutting.
Regards
Stefan
>
> Regards
> Stefan
[Back to original message]
|