You are here: Re: I want to display only a certain number of words from a database entry « PHP SQL « IT news, forums, messages
Re: I want to display only a certain number of words from a database entry

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация