sibrows Posted March 22, 2008 Share Posted March 22, 2008 Hello, this may be a really simple question but I can't seam to locate the answer using the all powerful Google! I'm trying to build a news reader on my site and instead of showing the whole news article I just want it to show the first 'x' words. My current, very cumbersome solution is to have two fields within a the database both manually filled when the article is created. I can't help thinking there is a better way of doing this. Thanks in advance. Simon Link to comment https://forums.phpfreaks.com/topic/97340-phpmysql-select-partial-text/ Share on other sites More sharing options...
Barand Posted March 22, 2008 Share Posted March 22, 2008 It would be a whole lot simpler if you show the first y characters instead of the first x words. Link to comment https://forums.phpfreaks.com/topic/97340-phpmysql-select-partial-text/#findComment-498103 Share on other sites More sharing options...
sibrows Posted March 22, 2008 Author Share Posted March 22, 2008 Thats fine. I have no problems with showing the first y characters but how do I do that? Link to comment https://forums.phpfreaks.com/topic/97340-phpmysql-select-partial-text/#findComment-498107 Share on other sites More sharing options...
Barand Posted March 22, 2008 Share Posted March 22, 2008 Let's say you want the first 100 chars, approx 20 words SELECT SUBSTRING(article, 1, 100) as snippet FROM newstable Link to comment https://forums.phpfreaks.com/topic/97340-phpmysql-select-partial-text/#findComment-498108 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.