Forums

PHP

This topic is locked

limit words

Posted 19 Dec 2001 19:09:34
1
has voted
19 Dec 2001 19:09:34 Keith Slater posted:
Hey Im make a search engine for a web site. When a user searches I want it to display the title and below it a short description. Well the short description in the database is too long and I want to limit how many words show up to like 25 or something.. How would I go about doing this??

Thanks


Keith Slater

Replies

Replied 19 Dec 2001 20:20:39
19 Dec 2001 20:20:39 Peter R replied:
In your recordset SQL you can add the following:

SELECT somefield, LEFT(yourfield ,100) As yourfield, someotherfield

The important part:

LEFT(yourfield ,100) As yourfield

...will display the first 100(or whatever you set it to) characters of the field you specify at "yourfield"

So your SQL could look like:

SELECT car_model, LEFT(car_description ,150) As car_description, car_price
FROM......

I know this isn't exactly what you're looking for, but it may make due until you find the exact answer. There's an extension to do what you're talking about, but I don't think there's a PHP version yet. I'm keepin' my eyes open for one.

Peter
Replied 20 Dec 2001 00:48:00
20 Dec 2001 00:48:00 Tim Green replied:
There will be an extension that does this for you that will available early in the New Year.

I will be releasing a Plus! pack for PHAkT which contains some alternative recordsets allowing you to easily create limited regions, cached recordsets and more.

In the meantime, you might want to check out the commercial extension IMPAkT, which also contains a limited recordset.

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>

Reply to this topic