You are here: Re: How do I display a certain number of words from a database field in MYSQL? « PHP SQL « IT news, forums, messages
Re: How do I display a certain number of words from a database field in MYSQL?

Posted by Bob Stearns on 11/16/05 05:35

Jonathan wrote:
> I have a project I am working on and I have a field in my description
> for the description of the cars and I am using a system that uses html
> templates driven by php/xml so I would need to wrtie them script in the
> html template...
>
> How do I limit the amount of words displayed.... and does these worked
> include numbers or how are number handled ? because there might be
> numbers as its a description of a muscle car...
>
> Please give me some advice or point me in the right direction...
>
Define "word" as characters between blanks. Then the following untested
code is an approximation to a solution to your problem.
Retrieve your description into $desc
$words = explode($desc, " ", $maxwords);
if(count($words)>=$maxwords) {
$words[$maxwords] = "";
$short_desc = implode(" ", $words)
}
else $short_desc = $desc;

 

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

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