creativkook Posted July 10, 2006 Share Posted July 10, 2006 If I wanted to return only part of a text entry in a database, for instance 50 words of a four paragraph entry as a sort of lead-in, is that possible? I can't seem to find a query for it. Does anyone know of one? Link to comment https://forums.phpfreaks.com/topic/14234-returning-only-part-of-a-text/ Share on other sites More sharing options...
redarrow Posted July 10, 2006 Share Posted July 10, 2006 substr Link to comment https://forums.phpfreaks.com/topic/14234-returning-only-part-of-a-text/#findComment-55869 Share on other sites More sharing options...
creativkook Posted July 10, 2006 Author Share Posted July 10, 2006 Where do I place that? Would it go after order by, where in the mysql query? Could someone give me an example? Thanks! Link to comment https://forums.phpfreaks.com/topic/14234-returning-only-part-of-a-text/#findComment-55872 Share on other sites More sharing options...
ShogunWarrior Posted July 10, 2006 Share Posted July 10, 2006 Say that your query returns a field named "text" then you might do this:while($row = mysql_fetch_assoc($result)){ $shortened = substr($row['text'],0,50);}Now shortened is the first 50 chars of "text". Link to comment https://forums.phpfreaks.com/topic/14234-returning-only-part-of-a-text/#findComment-55874 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.