adam84 Posted July 10, 2008 Share Posted July 10, 2008 I have a column (text) where the user enters like a profile about themselves. What I want to do is in the search results, I just want to grab the first 100 or so words from that column. Is there an sql function the would just return that or will I ahve to create a php function to do that? Awesome! Thanks Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 10, 2008 Share Posted July 10, 2008 Mysql has string functions that would allow you to return a specific number of characters (not words). You could form a more complex query that found the position of the 100'th white-space (assumes some kind of white space separates words) and then use that to return the characters up to that position. So, yes, you could do this in a query. Since you commonly would provide a link to display all the information when clicked, retrieving all the information one time and just displaying a portion of it while keeping the whole content available (in a session or perhaps even in a hidden <div> on the page) would result in the best performance. Quote Link to comment Share on other sites More sharing options...
Barand Posted July 10, 2008 Share Posted July 10, 2008 Since you commonly would provide a link to display all the information when clicked, retrieving all the information one time and just displaying a portion of it while keeping the whole content available (in a session or perhaps even in a hidden <div> on the page) would result in the best performance. As you are probably going to be displaying several extracts, then link to another page for the full article, I can't see the efficiency in getting the full text of all articles on that first page. The article wanted my not even be iin the first page so they're dragged down for no reason, slowing the query in the process. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.