Page 1 of 1

Urgent:Is there alternative to substr?:

Posted: Fri Oct 19, 2007 3:43 am
by tovia2000
Is there an alternatiuve to substr,

My problem:

I need to extract only the first 30 words from my body column from my mysql database table, for displaying on my pagination page,


Liek these gys do it down teh center of there page:, and display ... after some text:

http://www.articlealley.com/


how can i do this with top performance, i ahev thousands of records, is substr the only way?


Thanks in advance

kind regards


Tovia Singer

Posted: Fri Oct 19, 2007 4:37 am
by Kieran Huggins
you do want substr(), just not PHP's substr()!

MySQL's SUBSTR()
http://dev.mysql.com/doc/refman/5.0/en/ ... _substring

Or, if you prefer the first so many words:
http://dev.mysql.com/doc/refman/5.0/en/ ... ring-index

Posted: Fri Oct 19, 2007 11:13 am
by califdon
Kieran Huggins wrote:Or, if you prefer the first so many words:
http://dev.mysql.com/doc/refman/5.0/en/ ... ring-index
That's a very useful SQL function that I'd never noticed before! Thanks, Kieran.

Posted: Fri Oct 19, 2007 12:39 pm
by RobertGonzalez
For the record, substr is also available in Sybase.

PS I am moving this to Databases until it become clearly evident that this is a PHP Code question.