argrafic Posted May 8, 2008 Share Posted May 8, 2008 Hello, I want to display the records from a table in the database but i don't want all the info printed on screen because there are columns that have long text, so I wanted to know how can I get the first 5-10 words from the column and print those on screen? Thanks! Link to comment https://forums.phpfreaks.com/topic/104761-get-first-5-words-from-database-record/ Share on other sites More sharing options...
dezkit Posted May 8, 2008 Share Posted May 8, 2008 i think this is what you mean...? SELECT * FROM example ORDER BY id DESC LIMIT 5 Link to comment https://forums.phpfreaks.com/topic/104761-get-first-5-words-from-database-record/#findComment-536268 Share on other sites More sharing options...
DarkWater Posted May 8, 2008 Share Posted May 8, 2008 $words = explode(" ", $string); for ($i=0; $i<5; $i++) { $output .= $word[$i]; } $output .= "..."; //Add a ... to the end of it to signify more content. echo $output; =) Just put in the correct $string variable. Link to comment https://forums.phpfreaks.com/topic/104761-get-first-5-words-from-database-record/#findComment-536271 Share on other sites More sharing options...
dezkit Posted May 8, 2008 Share Posted May 8, 2008 wow, i really never pay attention to threads... Link to comment https://forums.phpfreaks.com/topic/104761-get-first-5-words-from-database-record/#findComment-536275 Share on other sites More sharing options...
DarkWater Posted May 8, 2008 Share Posted May 8, 2008 I was going to quote your post and ask what the hell you were doing, but I decided that it wouldn't be nice. =P Link to comment https://forums.phpfreaks.com/topic/104761-get-first-5-words-from-database-record/#findComment-536277 Share on other sites More sharing options...
argrafic Posted May 9, 2008 Author Share Posted May 9, 2008 Excellent!!! Thanks DarkWater!!!! Link to comment https://forums.phpfreaks.com/topic/104761-get-first-5-words-from-database-record/#findComment-536894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.