Re: Displaying few words from record in mySQL

From: Date: Sat, 08 Mar 2003 15:30:51 +0000
Subject: Re: Displaying few words from record in mySQL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-138755@lists.php.net to get a copy of this message
On Fri, 7 Mar 2003 10:22:01 -0800 (PST), Rahul.Brenda <rahul_brenda@yahoo.com> wrote:
Glory & Supreme Power What i'm looking to do is.. i want to display only the first few words of the record in my mySQL database.. For example.. i have a table with a field "title".. and let's say my last record has the value in title field as "This is going to be really cool" What i want to display is "this is going..." Basically this is for News Headlines. I have a page which displays news but on the first page of the site i have to give the first few words of the last 4 articles in the news table.. How can i do this? I have seen this in a lot of places but i dont know how to do this. Thanks, Rahul S. Johari __________________________________________________ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/
Make mysql do the work for you. select substring_index(title, ' ', 20), author from news order by date desc limit 4 // this particular string selects everything before the first 20 spaces of your title. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

« previous php.general (#138755) next »