How do I display a certain number of words from a database field in MYSQL?

How do I display a certain number of words from a database field in MYSQL?

am 16.11.2005 02:50:46 von Jonathan

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...

Re: How do I display a certain number of words from a database fieldin MYSQL?

am 16.11.2005 04:35:30 von Robert Stearns

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;

Re: How do I display a certain number of words from a database field in MYSQL?

am 16.11.2005 06:00:54 von Jonathan

Bob Stearns wrote:
> 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;



thanks , but where do I define the database row?